ton3-liteclient
Version:
TON Blockchain LiteClient
41 lines (35 loc) • 1.11 kB
text/typescript
import { StreamWriter, StreamReader } from '../../tl/stream';
import { crc32 } from '../../utils';
export interface BlockIdExt {
workchain: number;
shard: bigint;
seqno: number;
root_hash: Uint8Array;
file_hash: Uint8Array;
}
export const blockIdExt = {
tag: crc32(
'tonNode.blockIdExt workchain:int shard:long seqno:int root_hash:int256 file_hash:int256 = tonNode.BlockIdExt',
),
read: (dataReader: StreamReader): BlockIdExt => {
const workchain = dataReader.readInt32LE();
const shard = dataReader.readUint64LE();
const seqno = dataReader.readInt32LE();
const root_hash = dataReader.readBuffer(32);
const file_hash = dataReader.readBuffer(32);
return {
workchain,
shard,
seqno,
root_hash,
file_hash,
};
},
write: (bufferWriter: StreamWriter, blockId: BlockIdExt) => {
bufferWriter.writeInt32LE(blockId.workchain);
bufferWriter.writeUint64LE(blockId.shard);
bufferWriter.writeUint32LE(blockId.seqno);
bufferWriter.writeBuffer(blockId.root_hash);
bufferWriter.writeBuffer(blockId.file_hash);
},
};