Constructor
new CompactBlock(optionsopt, nullable)
Create a compact block.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object |
<optional> <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, 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
fromBlock(block, noncenullable) → {CompactBlock}
Inject properties from block.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
block |
Block | ||
nonce |
Buffer |
<nullable> |
- Source:
Returns:
- Type
- CompactBlock
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
init()
Initialize compact block and short id map.
- Source:
read(br)
Inject properties from buffer reader.
Parameters:
Name | Type | Description |
---|---|---|
br |
bio.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
write(bw)
Serialize block to buffer writer.
Parameters:
Name | Type | Description |
---|---|---|
bw |
BufioWriter |
- Source: