How to use ilp-logger - 5 common examples

To help you get started, we’ve selected a few ilp-logger examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github interledgerjs / ilp-protocol-stream / src / stream.ts View on Github external
constructor (opts: StreamOpts) {
    // Half-opened streams are not supported, support may be added in the future.
    super({ allowHalfOpen: false })
    this.id = opts.id
    this.isServer = opts.isServer
    this.log = createLogger(`ilp-protocol-stream:${this.isServer ? 'Server' : 'Client'}:Stream:${this.id}`)
    this.log.info('new stream created')

    this._totalSent = Long.UZERO
    this._totalReceived = Long.UZERO
    this._sendMax = Long.UZERO
    this._receiveMax = Long.UZERO
    this._outgoingHeldAmount = Long.UZERO

    this._sentEnd = false
    this._remoteSentEnd = false
    this.closed = false
    this.holds = {}

    this._incomingData = new OffsetSorter()
    this._outgoingData = new DataQueue()
    // TODO we might want to merge this with the _outgoingData queue data structure
github interledgerjs / ilp-protocol-stream / src / connection.ts View on Github external
this.connectionTag = opts.connectionTag
    this.maxStreamId = 2 * (opts.maxRemoteStreams || DEFAULT_MAX_REMOTE_STREAMS)
    this.maxBufferedData = opts.connectionBufferSize || MAX_DATA_SIZE * 2
    this.minExchangeRatePrecision = opts.minExchangeRatePrecision || DEFAULT_MINIMUM_EXCHANGE_RATE_PRECISION
    this.exchangeRate = opts.exchangeRate === undefined
      ? undefined
      : Rational.fromNumber(opts.exchangeRate, true)
    this.idleTimeout = opts.idleTimeout || DEFAULT_IDLE_TIMEOUT
    this.lastActive = new Date()

    this.nextPacketSequence = 1
    // TODO should streams be a Map or just an object?
    this.streams = new Map()
    this.closedStreams = new Set()
    this.nextStreamId = (this.isServer ? 2 : 1)
    this.log = createLogger(`ilp-protocol-stream:${this.isServer ? 'Server' : 'Client'}:Connection`)
    this.sending = false
    this.connected = false
    this.closed = true
    this.queuedFrames = []

    this.congestion = new CongestionController({
      maximumPacketAmount: opts.maximumPacketAmount === undefined
        ? undefined
        : Long.fromString(opts.maximumPacketAmount, true)
    })
    this.retryDelay = RETRY_DELAY_START

    this.remoteKnowsOurAccount = this.isServer
    this.remoteMaxStreamId = DEFAULT_MAX_REMOTE_STREAMS * 2

    this.remoteMaxOffset = this.maxBufferedData
github interledgerjs / ilp-protocol-stream / src / pool.ts View on Github external
import createLogger from 'ilp-logger'
import * as IlpPacket from 'ilp-packet'
import { Connection, BuildConnectionOpts } from './connection'
import * as cryptoHelper from './crypto'

const log = createLogger('ilp-protocol-stream:Pool')

interface ConnectionEvent {
  (connection: Connection): void
}

type ConnectionOptions = Omit

export class ServerConnectionPool {
  private serverSecret: Buffer
  private connectionOpts: ConnectionOptions
  private onConnection: ConnectionEvent
  private activeConnections: { [id: string]: Connection }
  private pendingConnections: { [id: string]: Promise }
  private closedConnections: Set

  constructor (
github interledgerjs / ilp-protocol-stream / src / util / congestion.ts View on Github external
import * as Long from 'long'
import createLogger from 'ilp-logger'
import * as IlpPacket from 'ilp-packet'
import { Reader } from 'oer-utils'
import {
  checkedAdd,
  checkedMultiply,
  maxLong,
  minLong,
  multiplyDivideFloor
} from './long'

const log = createLogger('ilp-protocol-stream:Congestion')

interface CongestionOptions {
  /** Maximum amount per packet, even if F08 reports larger */
  maximumPacketAmount?: Long
}

export class CongestionController {
  /** Used to probe for the Maximum Packet Amount if the connectors don't tell us directly */
  private _testMaximumPacketAmount: Long
  /** The path's Maximum Packet Amount, discovered through F08 errors */
  private _maximumPacketAmount: Long
  /** The sender-chosen maximum packet amount. */
  private _fixedPacketAmount: Long

  constructor (opts: CongestionOptions) {
    this._testMaximumPacketAmount = Long.MAX_UNSIGNED_VALUE
github interledgerjs / ilp-protocol-stream / src / index.ts View on Github external
export async function createConnection (opts: CreateConnectionOpts): Promise {
  const plugin = opts.plugin
  await plugin.connect()
  const log = createLogger('ilp-protocol-stream:Client')
  const { clientAddress, assetCode, assetScale } = await ILDCP.fetch(plugin.sendData.bind(plugin))
  const connection = await Connection.build({
    ...opts,
    sourceAccount: clientAddress,
    assetCode,
    assetScale,
    isServer: false,
    plugin
  })
  plugin.registerDataHandler(async (data: Buffer): Promise => {
    let prepare: IlpPacket.IlpPrepare
    try {
      prepare = IlpPacket.deserializeIlpPrepare(data)
    } catch (err) {
      log.error('got data that is not an ILP Prepare packet: %h', data)
      return IlpPacket.serializeIlpReject({

ilp-logger

Logging utility for Interledger modules

Apache-2.0
Latest version published 2 years ago

Package Health Score

43 / 100
Full package analysis

Popular ilp-logger functions

Similar packages