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

Members

hashes :Array.<Hash>

Type:
Source:

txs :Array.<TX>

Type:
  • Array.<TX>
Source:

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 BloomFilter
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(viewopt, heightopt) → {Object}

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

Parameters:
Name Type Attributes Description
view CoinView <optional>
height Number <optional>
Source:
Returns:
Type
Object

fromJSON(json)

Inject properties from json object.

Parameters:
Name Type Description
json Object
Source:

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(networkopt, viewopt, heightopt) → {Object}

Convert the block to an object suitable for JSON serialization.

Parameters:
Name Type Attributes Description
network Network <optional>
view CoinView <optional>
height Number <optional>
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

read(br)

Inject properties from buffer reader.

Parameters:
Name Type Description
br bio.BufferReader
Source:

refresh(allopt, nullable)

Clear any cached values.

Parameters:
Name Type Attributes Description
all Boolean <optional>
<nullable>

Clear transactions.

Source:

toHeaders() → {Headers}

Convert the block to a headers object.

Source:
Returns:
Type
Headers

verifyBody() → {Boolean}

Verify the partial merkletree.

Source:
Returns:
Type
Boolean

write(bw) → {BufioWriter}

Write the merkleblock to a buffer writer.

Parameters:
Name Type Description
bw BufioWriter
Source:
Returns:
Type
BufioWriter