new CompactBlock(data)
A block object which is essentially a "placeholder" for a full Block object. The v8 garbage collector's head will explode if there is too much data on the javascript heap. Blocks can currently be up to 1mb in size. In the future, they may be 2mb, 8mb, or maybe 20mb, who knows? A CompactBlock is an optimization in BCoin which defers parsing of the serialized transactions (the block Buffer) until the block has passed through the chain queue and is about to enter the chain. This keeps a lot data off of the javascript heap for most of the time a block even exists in memory, and manages to keep a lot of strain off of the garbage collector. Having 500mb of blocks on the js heap would not be a good thing.
Parameters:
Name | Type | Description |
---|---|---|
data |
Object |
Properties:
Name | Type | Description |
---|---|---|
version |
Number | Block version. Note that BCoin reads versions as unsigned despite them being signed on the protocol level. This number will never be negative. |
prevBlock |
Hash | Previous block hash. |
merkleRoot |
Hash | Merkle root hash. |
ts |
Number | Timestamp. |
bits |
Number | |
nonce |
Number | |
totalTX |
Number | Transaction count. |
height |
Number | Block height (-1 if not present). |
coinbaseHeight |
Number | The coinbase height which was extracted by the parser (the coinbase is the only transaction we parse ahead of time). |
_raw |
Buffer | The raw block data. |
rhash |
ReversedHash | Reversed block hash (uint256le). |
- Source:
Methods
(static) isCompactBlock(obj) → {Boolean}
Test an object to see if it is a CompactBlock.
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object |
- Source:
Returns:
- Type
- Boolean
getCoinbaseHeight() → {Number}
Retrieve the coinbase height from the coinbase input script (already extracted in actuality).
- Source:
Returns:
height (-1 if not present).
- Type
- Number
toBlock() → {Block}
Parse the serialized block data and create an actual Block.
- Source:
Throws:
Parse error
Returns:
- Type
- Block