Class: MemBlock

primitives~MemBlock()

Mem Block 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 MemBlock 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.

Constructor

new MemBlock()

Create a mem block.

Extends:
  • AbstractBlock
Source:

Extends

  • AbstractBlock

Methods

(static) fromRaw(data) → {MemBlock}

Insantiate a memblock from serialized data.

Parameters:
Name Type Description
data Buffer
Source:
Returns:
Type
MemBlock

(static) isMemBlock(obj) → {Boolean}

Test whether an object is a MemBlock.

Parameters:
Name Type Description
obj Object
Source:
Returns:
Type
Boolean

(private) fromRaw(data)

Inject properties from serialized data.

Parameters:
Name Type Description
data Buffer
Source:

getCoinbaseHeight() → {Number}

Retrieve the coinbase height from the coinbase input script.

Source:
Returns:

height (-1 if not present).

Type
Number

getSize() → {Number}

Get the full block size.

Source:
Returns:
Type
Number

isMemory() → {Boolean}

Test whether the block is a memblock.

Source:
Returns:
Type
Boolean

(private) parseCoinbaseHeight() → {Number}

Parse the coinbase height from the coinbase input script.

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

toHead() → {Buffer}

Serialize the block headers.

Source:
Returns:
Type
Buffer

toHeaders() → {Headers}

Convert the block to a headers object.

Source:
Returns:
Type
Headers

toNormal() → {Buffer}

Return serialized block data.

Source:
Returns:
Type
Buffer

toRaw() → {Buffer}

Return serialized block data.

Source:
Returns:
Type
Buffer

verifyBody() → {Boolean}

Verify the block.

Source:
Returns:
Type
Boolean