Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | 1x 1x 1x | import { BufferReader, BufferWriter } from '@node-dlc/bufio';
import { MessageType } from '../MessageType';
import { IWireMessage } from './IWireMessage';
export class GossipTimestampFilterMessage implements IWireMessage {
public static deserialize(payload: Buffer): GossipTimestampFilterMessage {
const instance = new GossipTimestampFilterMessage();
const reader = new BufferReader(payload);
reader.readUInt16BE(); // read off type
instance.chainHash = reader.readBytes(32);
instance.firstTimestamp = reader.readUInt32BE();
instance.timestampRange = reader.readUInt32BE();
return instance;
}
public type: MessageType = MessageType.GossipTimestampFilter;
public chainHash: Buffer;
public firstTimestamp: number;
public timestampRange: number;
public serialize(): Buffer {
const len =
2 + // type
32 + // chain_hash
4 + // first_timestamp
4; // timestamp_range
const writer = new BufferWriter(Buffer.alloc(len));
writer.writeUInt16BE(this.type);
writer.writeBytes(this.chainHash);
writer.writeUInt32BE(this.firstTimestamp);
writer.writeUInt32BE(this.timestampRange);
return writer.toBuffer();
}
}
|