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 | |
time |
Number | |
bits |
Number | |
nonce |
Number | |
height |
Number | |
chainwork |
BN | |
rhash |
Hash |
- 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) fromJSON(json) → {ChainEntry}
Instantiate block from jsonified object.
Parameters:
Name | Type | Description |
---|---|---|
json |
Object |
- Source:
Returns:
- Type
- ChainEntry
(static) fromOptions(options, prev) → {ChainEntry}
Instantiate chainentry from options.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | |
prev |
ChainEntry | Previous entry. |
- Source:
Returns:
- Type
- ChainEntry
(static) fromRaw(data) → {ChainEntry}
Deserialize the entry.
Parameters:
Name | Type | Description |
---|---|---|
data |
Buffer |
- 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
(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:
(private) fromRaw(data)
Inject properties from serialized data.
Parameters:
Name | Type | Description |
---|---|---|
data |
Buffer |
- Source:
getChainwork() → {BN}
Calculate the chainwork by adding proof to previous chainwork.
- Source:
Returns:
chainwork
- Type
- BN
getProof() → {BN}
Calculate the proof: (1 << 256) / (target + 1)
- Source:
Returns:
proof
- Type
- BN
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
inspectSymbol() → {Object}
Return a more user-friendly object.
- Source:
Returns:
- Type
- Object
isGenesis() → {Boolean}
Test against the genesis block.
- Source:
Returns:
- Type
- Boolean
rhash() → {Hash}
Get little-endian block hash.
- Source:
Returns:
- Type
- Hash
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
toJSON() → {Object}
Serialize the entry to an object more suitable for JSON serialization.
- Source:
Returns:
- Type
- Object
toRaw() → {Buffer}
Serialize the entry to internal database format.
- Source:
Returns:
- Type
- Buffer