UNPKG

@neo-one/node-protocol-esnext-esm

Version:

NEO•ONE NEO node and consensus protocol.

30 lines (28 loc) 1.04 kB
import { createSerializeWire } from '@neo-one/client-common-esnext-esm'; import { BinaryReader } from '@neo-one/node-core-esnext-esm'; import { assertInventoryType } from './InventoryType'; export class InvPayload { constructor({ type, hashes }) { this.serializeWire = createSerializeWire(this.serializeWireBase.bind(this)); this.type = type; this.hashes = hashes; } static deserializeWireBase({ reader }) { const type = assertInventoryType(reader.readUInt8()); const hashes = reader.readArray(() => reader.readUInt256()); return new this({ type, hashes }); } static deserializeWire(options) { return this.deserializeWireBase({ context: options.context, reader: new BinaryReader(options.buffer), }); } serializeWireBase(writer) { writer.writeUInt8(this.type); writer.writeArray(this.hashes, (value) => { writer.writeUInt256(value); }); } } //# sourceMappingURL=InvPayload.js.map