UNPKG

@neo-one/node-protocol

Version:

NEO•ONE NEO node and consensus protocol.

67 lines (65 loc) 2.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MerkleBlockPayload = void 0; const client_common_1 = require("@neo-one/client-common"); const node_core_1 = require("@neo-one/node-core"); class MerkleBlockPayload extends node_core_1.BlockBase { constructor({ version, previousHash, merkleRoot, timestamp, index, consensusData, nextConsensus, script, transactionCount, hashes, flags, }) { super({ version, previousHash, merkleRoot, timestamp, index, consensusData, nextConsensus, script, }); this.transactionCount = transactionCount; this.hashes = hashes; this.flags = flags; this.merkleBlockPayloadSizeInternal = node_core_1.utils.lazy(() => super.size + client_common_1.IOHelper.sizeOfUInt32LE + client_common_1.IOHelper.sizeOfArray(this.hashes, () => client_common_1.IOHelper.sizeOfUInt256) + client_common_1.IOHelper.sizeOfVarBytesLE(this.flags)); } static deserializeWireBase(options) { const { reader } = options; const blockBase = super.deserializeBlockBaseWireBase(options); const transactionCount = reader.readVarUIntLE(node_core_1.utils.INT_MAX_VALUE).toNumber(); const hashes = reader.readArray(() => reader.readUInt256()); const flags = reader.readVarBytesLE(); return new this({ version: blockBase.version, previousHash: blockBase.previousHash, merkleRoot: blockBase.merkleRoot, timestamp: blockBase.timestamp, index: blockBase.index, consensusData: blockBase.consensusData, nextConsensus: blockBase.nextConsensus, script: blockBase.script, transactionCount, hashes, flags, }); } static deserializeWire(options) { return this.deserializeWireBase({ context: options.context, reader: new node_core_1.BinaryReader(options.buffer), }); } get size() { return this.merkleBlockPayloadSizeInternal(); } serializeWireBase(writer) { super.serializeWireBase(writer); writer.writeVarUIntLE(this.transactionCount); writer.writeArray(this.hashes, (hash) => { writer.writeUInt256(hash); }); writer.writeVarBytesLE(this.flags); } } exports.MerkleBlockPayload = MerkleBlockPayload; //# sourceMappingURL=MerkleBlockPayload.js.map