UNPKG

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

Version:

NEO•ONE NEO node and consensus protocol.

33 lines (31 loc) 1.18 kB
import { createSerializeWire, InvalidFormatError, } from '@neo-one/client-common-esnext-esm'; import { BinaryReader } from '@neo-one/node-core-esnext-esm'; export class FilterLoadPayload { constructor({ filter, k, tweak }) { this.serializeWire = createSerializeWire(this.serializeWireBase.bind(this)); this.filter = filter; this.k = k; this.tweak = tweak; } static deserializeWireBase({ reader }) { const filter = reader.readVarBytesLE(36000); const k = reader.readUInt8(); const tweak = reader.readUInt32LE(); if (k > 50) { throw new InvalidFormatError(`Expected BinaryReader\'s readUInt8(0) to be less than 50. Received: ${k}`); } return new this({ filter, k, tweak }); } static deserializeWire(options) { return this.deserializeWireBase({ context: options.context, reader: new BinaryReader(options.buffer), }); } serializeWireBase(writer) { writer.writeVarBytesLE(this.filter); writer.writeUInt8(this.k); writer.writeUInt32LE(this.tweak); } } //# sourceMappingURL=FilterLoadPayload.js.map