Class: MerkleBlock

primitives~MerkleBlock(options)

Merkle Block Represents a merkle (filtered) block.

Constructor

new MerkleBlock(options)

Create a merkle block.

Extends:
  • AbstractBlock
Parameters:
Name Type Description
options Object
Source:

Extends

  • AbstractBlock

Methods

(static) fromBlock(block, filter) → {MerkleBlock}

Create a merkleblock from a Block object, passing it through a filter first. This will build the partial merkle tree.

Parameters:
Name Type Description
block Block
filter Bloom
Source:
Returns:
Type
MerkleBlock

(static) fromHashes(block, hashes) → {MerkleBlock}

Create a merkleblock from an array of txids. This will build the partial merkle tree.

Parameters:
Name Type Description
block Block
hashes Array.<Hash>
Source:
Returns:
Type
MerkleBlock

(static) fromMatches(block, matches) → {MerkleBlock}

Create a merkleblock from an array of matches. This will build the partial merkle tree.

Parameters:
Name Type Description
block Block
matches Array.<Number>
Source:
Returns:
Type
MerkleBlock

(static) isMerkleBlock(obj) → {Boolean}

Test whether an object is a MerkleBlock.

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

(private) checkBody() → {Array}

Verify the partial merkletree.

Source:
Returns:

[valid, reason, score]

Type
Array

(private) extractTree() → {Object}

Extract the matches from partial merkle tree and calculate merkle root.

Source:
Returns:
Type
Object

format(view, height) → {Object}

Inspect the block and return a more user-friendly representation of the data.

Parameters:
Name Type Description
view CoinView
height Number
Source:
Returns:
Type
Object

(private) fromJSON(json)

Inject properties from json object.

Parameters:
Name Type Description
json Object
Source:

(private) fromOptions(options)

Inject properties from options object.

Parameters:
Name Type Description
options Object
Source:

getCoinbaseHeight() → {Number}

Extract the coinbase height (always -1).

Source:
Returns:
Type
Number

getJSON(network, view, height) → {Object}

Convert the block to an object suitable for JSON serialization.

Parameters:
Name Type Description
network Network
view CoinView
height Number
Source:
Returns:
Type
Object

getSize() → {Number}

Get merkleblock size.

Source:
Returns:

Size.

Type
Number

getTree() → {Object}

Extract the matches from partial merkle tree and calculate merkle root.

Source:
Returns:
Type
Object

hasTX(hash) → {Boolean}

Test the block's matched transaction vector against a hash.

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

indexOf(hash) → {Number}

Test the block's matched transaction vector against a hash.

Parameters:
Name Type Description
hash Hash
Source:
Returns:

Index.

Type
Number

(private) read(br)

Inject properties from buffer reader.

Parameters:
Name Type Description
br BufferReader
Source:

refresh(allnullable)

Clear any cached values.

Parameters:
Name Type Attributes Description
all Boolean <nullable>

Clear transactions.

Source:

toHeaders() → {Headers}

Convert the block to a headers object.

Source:
Returns:
Type
Headers

(private) verifyBody() → {Boolean}

Verify the partial merkletree.

Source:
Returns:
Type
Boolean

write(bw)

Write the merkleblock to a buffer writer.

Parameters:
Name Type Description
bw BufferWriter
Source: