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, prevopt, nullable) → {ChainEntry}

Instantiate chainentry from block.

Parameters:
Name Type Attributes Description
block Block | MerkleBlock
prev ChainEntry <optional>
<nullable>

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

fromBlock(block, prevopt, nullable) → {this}

Inject properties from block.

Parameters:
Name Type Attributes Description
block Block | MerkleBlock
prev ChainEntry <optional>
<nullable>

Previous entry.

Source:
Returns:
Type
this

fromJSON(json) → {this}

Inject properties from json object.

Parameters:
Name Type Description
json Object
Source:
Returns:
Type
this

fromOptions(options) → {this}

Inject properties from options.

Parameters:
Name Type Description
options Object
Source:
Returns:
Type
this

getChainwork(prevopt, nullable) → {BN}

Calculate the chainwork by adding proof to previous chainwork.

Parameters:
Name Type Attributes Description
prev ChainEntry <optional>
<nullable>

Previous entry.

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

read(br)

Inject properties from serialized data.

Parameters:
Name Type Description
br bio.BufferReader
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(bw) → {BufioWriter}

Serialize the entry to internal database format.

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