Class: ChainEntry

blockchain.ChainEntry(optionsnullable)

Chain Entry Represents an entry in the chain.

Constructor

new ChainEntry(optionsnullable)

Create a chain entry.

Parameters:
Name Type Attributes Description
options Object <nullable>
Properties:
Name Type Description
hash Hash
version Number
prevBlock Hash
merkleRoot Hash
witnessRoot Hash
treeRoot Hash
reservedRoot Hash
time Number
bits Number
nonce Buffer
height Number
chainwork BN
Source:

Members

(static, constant) MAX_CHAINWORK :BN

The max chainwork (1 << 256).

Type:
Source:

Methods

(static) fromBlock(block, prev) → {ChainEntry}

Instantiate chainentry from block.

Parameters:
Name Type Description
block Block | MerkleBlock
prev ChainEntry

Previous entry.

Source:
Returns:
Type
ChainEntry

(static) isChainEntry(obj) → {Boolean}

Test whether an object is a ChainEntry.

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

format() → {Object}

Return a more user-friendly object.

Source:
Returns:
Type
Object

(private) fromBlock(block, prev)

Inject properties from block.

Parameters:
Name Type Description
block Block | MerkleBlock
prev ChainEntry

Previous entry.

Source:

(private) fromJSON(json)

Inject properties from json object.

Parameters:
Name Type Description
json Object
Source:

(private) fromOptions(options)

Inject properties from options.

Parameters:
Name Type Description
options Object
Source:

getChainwork() → {BN}

Calculate the chainwork by adding proof to previous chainwork.

Source:
Returns:

chainwork

Type
BN

getJSON() → {Object}

Serialize the entry to an object more suitable for JSON serialization.

Source:
Returns:
Type
Object

getProof() → {BN}

Calculate the proof: (1 << 256) / (target + 1)

Source:
Returns:

proof

Type
BN

getSize() → {Number}

Get serialization size.

Source:
Returns:
Type
Number

hasBit(bit) → {Boolean}

Test whether the entry contains a version bit.

Parameters:
Name Type Description
bit Number
Source:
Returns:
Type
Boolean

hasUnknown(network) → {Boolean}

Test whether the entry contains an unknown version bit.

Parameters:
Name Type Description
network Network
Source:
Returns:
Type
Boolean

isGenesis() → {Boolean}

Test against the genesis block.

Source:
Returns:
Type
Boolean

(private) read(data)

Inject properties from serialized data.

Parameters:
Name Type Description
data Buffer
Source:

toHeaders() → {Headers}

Convert the entry to a headers object.

Source:
Returns:
Type
Headers

toInv() → {InvItem}

Convert the entry to an inv item.

Source:
Returns:
Type
InvItem

write() → {Buffer}

Serialize the entry to internal database format.

Source:
Returns:
Type
Buffer