Class: CompactBlock

net/bip152~CompactBlock(optionsnullable)

Compact Block Represents a compact block (bip152): cmpctblock packet.

Constructor

new CompactBlock(optionsnullable)

Create a compact block.

Parameters:
Name Type Attributes Description
options Object <nullable>
Properties:
Name Type Description
keyNonce Buffer | null

Nonce for siphash key.

ids Array.<Number>

Short IDs.

ptx Array.<Object>

Prefilled transactions.

available Array.<TX>

Available transaction vector.

idMap Object

Map of short ids to indexes.

count Number

Transactions resolved.

sipKey Buffer | null

Siphash key.

Source:
See:

Extends

  • AbstractBlock

Methods

(static) fromBlock(block, noncenullable) → {CompactBlock}

Instantiate compact block from a block.

Parameters:
Name Type Attributes Description
block Block
nonce Buffer <nullable>
Source:
Returns:
Type
CompactBlock

fillMempool(mempool) → {Boolean}

Attempt to fill missing transactions from mempool.

Parameters:
Name Type Description
mempool Mempool
Source:
Returns:
Type
Boolean

fillMissing(res) → {Boolean}

Attempt to fill missing transactions from TXResponse.

Parameters:
Name Type Description
res TXResponse
Source:
Returns:
Type
Boolean

(private) fromBlock(block, noncenullable) → {CompactBlock}

Inject properties from block.

Parameters:
Name Type Attributes Description
block Block
nonce Buffer <nullable>
Source:
Returns:
Type
CompactBlock

(private) fromOptions(options)

Inject properties from options object.

Parameters:
Name Type Description
options Object
Source:

(private) getKey() → {Buffer}

Initialize the siphash key.

Source:
Returns:
Type
Buffer

getSize() → {Number}

Calculate block serialization size.

Source:
Returns:
Type
Number

hasIndex(index) → {Boolean}

Test whether an index is available.

Parameters:
Name Type Description
index Number
Source:
Returns:
Type
Boolean

(private) init()

Initialize compact block and short id map.

Source:

(private) read(br)

Inject properties from buffer reader.

Parameters:
Name Type Description
br BufferReader
Source:

sid(hash) → {Number}

Calculate a transaction short ID.

Parameters:
Name Type Description
hash Hash
Source:
Returns:
Type
Number

toBlock() → {Block}

Convert completely filled compact block to a regular block.

Source:
Returns:
Type
Block

toHeaders() → {Headers}

Convert block to headers.

Source:
Returns:
Type
Headers

toRequest() → {TXRequest}

Convert block to a TXRequest containing missing indexes.

Source:
Returns:
Type
TXRequest

verifyBody() → {Boolean}

Verify the block.

Source:
Returns:
Type
Boolean

(private) write(bw)

Serialize block to buffer writer.

Parameters:
Name Type Description
bw BufferWriter
Source: