@neo-one/node-protocol
Version:
NEO•ONE NEO node and consensus protocol.
62 lines (60 loc) • 2.19 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VersionPayload = exports.SERVICES = void 0;
const client_common_1 = require("@neo-one/client-common");
const node_core_1 = require("@neo-one/node-core");
const bn_js_1 = require("bn.js");
exports.SERVICES = {
NODE_NETWORK: new bn_js_1.BN(1),
};
class VersionPayload {
constructor({ protocolVersion, services, timestamp, port, nonce, userAgent, startHeight, relay, }) {
this.serializeWire = client_common_1.createSerializeWire(this.serializeWireBase.bind(this));
this.protocolVersion = protocolVersion;
this.services = services;
this.timestamp = timestamp;
this.port = port;
this.nonce = nonce;
this.userAgent = userAgent;
this.startHeight = startHeight;
this.relay = relay;
}
static deserializeWireBase({ reader }) {
const protocolVersion = reader.readUInt32LE();
const services = reader.readUInt64LE();
const timestamp = reader.readUInt32LE();
const port = reader.readUInt16LE();
const nonce = reader.readUInt32LE();
const userAgent = reader.readVarString(1024);
const startHeight = reader.readUInt32LE();
const relay = reader.readBoolean();
return new this({
protocolVersion,
services,
timestamp,
port,
nonce,
userAgent,
startHeight,
relay,
});
}
static deserializeWire(options) {
return this.deserializeWireBase({
context: options.context,
reader: new node_core_1.BinaryReader(options.buffer),
});
}
serializeWireBase(writer) {
writer.writeUInt32LE(this.protocolVersion);
writer.writeUInt64LE(this.services);
writer.writeUInt32LE(this.timestamp);
writer.writeUInt16LE(this.port);
writer.writeUInt32LE(this.nonce);
writer.writeVarString(this.userAgent);
writer.writeUInt32LE(this.startHeight);
writer.writeBoolean(this.relay);
}
}
exports.VersionPayload = VersionPayload;
//# sourceMappingURL=VersionPayload.js.map