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AC,IAAI,CAAC,gBAAgB;gBAClC,OAAO,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAA;YACtE;gBACE,GAAG,CAAC,KAAK,CAAC,iDAAiD,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;gBAChF,MAAM,IAAI,kBAAkB,CAAC,qCAAqC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;SAChF;IACH,CAAC;CACF;AAnCD,uBAmCC","sourcesContent":["import * as IlpPacket from 'ilp-packet'\nimport Config from '../services/config'\nimport Accounts from '../services/accounts'\nimport RouteBroadcaster from '../services/route-broadcaster'\nimport RouteBuilder from '../services/route-builder'\nimport IlpPrepareController from '../controllers/ilp-prepare'\nimport { create as createLogger } from '../common/log'\nconst log = createLogger('core-middleware')\nimport reduct = require('reduct')\nconst { InvalidPacketError } = IlpPacket.Errors\n\nexport default class Core {\n protected config: Config\n protected accounts: Accounts\n protected routeBroadcaster: RouteBroadcaster\n protected routeBuilder: RouteBuilder\n protected ilpPrepareController: IlpPrepareController\n\n constructor (deps: reduct.Injector) {\n this.config = deps(Config)\n this.accounts = deps(Accounts)\n this.routeBroadcaster = deps(RouteBroadcaster)\n this.routeBuilder = deps(RouteBuilder)\n\n this.ilpPrepareController = deps(IlpPrepareController)\n }\n\n async processData (data: Buffer, accountId: string, outbound: (data: Buffer, accountId: string) => Promise<Buffer>): Promise<Buffer> {\n if (!this.accounts.getInfo(accountId)) {\n log.warn('got data from unknown account id. accountId=%s', accountId)\n throw new Error('got data from unknown account id. accountId=' + accountId)\n }\n\n if (!Buffer.isBuffer(data)) {\n log.error('data handler was passed a non-buffer. typeof=%s data=%s', typeof data, data)\n throw new Error('data handler was passed a non-buffer. typeof=' + typeof data)\n }\n\n switch (data[0]) {\n case IlpPacket.Type.TYPE_ILP_PREPARE:\n return this.ilpPrepareController.sendData(data, accountId, outbound)\n default:\n log.error('received invalid packet type. source=%s type=%s', accountId, data[0])\n throw new InvalidPacketError('invalid packet type received. type=' + data[0])\n }\n }\n}\n"]}
\No newline at end of file