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. |
Extends
- AbstractBlock
Methods
(static) fromBlock(block, witness, noncenullable) → {CompactBlock}
Instantiate compact block from a block.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
block |
Block | ||
witness |
Boolean | ||
nonce |
Buffer |
<nullable> |
- Source:
Returns:
- Type
- CompactBlock
(static) fromOptions(options) → {CompactBlock}
Instantiate compact block from options.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
- Source:
Returns:
- Type
- CompactBlock
(static) fromRaw(data, encnullable) → {CompactBlock}
Instantiate a block from serialized data.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
data |
Buffer | ||
enc |
String |
<nullable> |
- Source:
Returns:
- Type
- CompactBlock
fillMempool(witness, mempool) → {Boolean}
Attempt to fill missing transactions from mempool.
Parameters:
Name | Type | Description |
---|---|---|
witness |
Boolean | |
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) frameRaw(witness) → {Buffer}
Serialize compact block.
Parameters:
Name | Type | Description |
---|---|---|
witness |
Boolean |
- Source:
Returns:
- Type
- Buffer
(private) fromBlock(block, witness, noncenullable) → {CompactBlock}
Inject properties from block.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
block |
Block | ||
witness |
Boolean | ||
nonce |
Buffer |
<nullable> |
- Source:
Returns:
- Type
- CompactBlock
(private) fromOptions(options)
Inject properties from options object.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
- Source:
(private) fromRaw(data)
Inject properties from serialized data.
Parameters:
Name | Type | Description |
---|---|---|
data |
Buffer |
- Source:
(private) getKey() → {Buffer}
Initialize the siphash key.
- Source:
Returns:
- Type
- Buffer
getSize(witness) → {Number}
Calculate block serialization size.
Parameters:
Name | Type | Description |
---|---|---|
witness |
Boolean |
- 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:
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
toNormal() → {Buffer}
Serialize compact block without witness data.
- Source:
Returns:
- Type
- Buffer
toNormalWriter(bw)
Write serialized block to a buffer writer (excludes witness data).
Parameters:
Name | Type | Description |
---|---|---|
bw |
BufferWriter |
- Source:
toRaw() → {Buffer}
Serialize compact block with witness data.
- Source:
Returns:
- Type
- Buffer
toRequest() → {TXRequest}
Convert block to a TXRequest containing missing indexes.
- Source:
Returns:
- Type
- TXRequest
toWriter(bw)
Write serialized block to a buffer writer (includes witness data).
Parameters:
Name | Type | Description |
---|---|---|
bw |
BufferWriter |
- Source:
verifyBody() → {Boolean}
Verify the block.
- Source:
Returns:
- Type
- Boolean
(private) writeRaw(bw, witness)
Serialize block to buffer writer.
Parameters:
Name | Type | Description |
---|---|---|
bw |
BufferWriter | |
witness |
Boolean |
- Source: