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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | 1x 1x 1x 1x 1x | import { BufferReader, BufferWriter } from '@node-dlc/bufio';
import { MessageType } from '../MessageType';
import { IDlcMessage } from './DlcMessage';
/**
* DlcInfo message contains list of buffers
*/
export class DlcInfo implements IDlcMessage {
public static type = MessageType.DlcInfo;
public static deserialize(buf: Buffer): DlcInfo {
const reader = new BufferReader(buf);
const type = Number(reader.readUInt16BE());
switch (type) {
case MessageType.DlcInfoV0:
return DlcInfo.deserializeV0(buf);
default:
throw new Error(`DLC Info message type must be DlcInfoV0`);
}
}
/**
* Deserializes an dlc_info message
* @param buf
*/
private static deserializeV0(buf: Buffer): DlcInfo {
const instance = new DlcInfo();
const reader = new BufferReader(buf);
reader.readUInt16BE(); // read type
instance.numDlcOffers = reader.readUInt32BE();
instance.numDlcAccepts = reader.readUInt32BE();
instance.numDlcSigns = reader.readUInt32BE();
instance.numDlcCancels = reader.readUInt32BE();
instance.numDlcCloses = reader.readUInt32BE();
instance.numDlcTransactions = reader.readUInt32BE();
return instance;
}
/**
* The type for dlc_info message
*/
public type = DlcInfo.type;
public numDlcOffers: number;
public numDlcAccepts: number;
public numDlcSigns: number;
public numDlcCancels: number;
public numDlcCloses: number;
public numDlcTransactions: number;
/**
* Serializes the dlc_info message into a Buffer
*/
public serialize(): Buffer {
const writer = new BufferWriter();
writer.writeUInt16BE(this.type);
writer.writeUInt32BE(this.numDlcOffers);
writer.writeUInt32BE(this.numDlcAccepts);
writer.writeUInt32BE(this.numDlcSigns);
writer.writeUInt32BE(this.numDlcCancels);
writer.writeUInt32BE(this.numDlcCloses);
writer.writeUInt32BE(this.numDlcTransactions);
return writer.toBuffer();
}
}
// Legacy support - keeping old class name as alias
export const DlcInfoV0 = DlcInfo;
export type DlcInfoV0 = DlcInfo;
|