Package Exports
- ethereumjs-block
- ethereumjs-block/header
- ethereumjs-block/header.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ethereumjs-block) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
SYNOPSIS
Implements schema and functions related to Etheruem's block.
INSTALL
npm install ethereumjs-block
BOWSER
This module work with browserify
CONTACT
Scrollback or #ethereumjs on freenode
API
Block
new Block([data])
Creates a new block object
data
- the serialized block (usually from the network) in a array of buffers as described in the wire protocol
Block
Properties
header
- the block'sheader
transactionReceipt
- an array ofTransactionReceipt
in the blockuncleList
- an array of uncleheaders
raw
- an array of buffers containing the raw blocks.
Block
Methods
block.genTxTrie(cb)
Generates the transaction trie. This must be done before doing validation
cb
- the callback
block.hash()
Returns the sha3-256 hash of the RLP encoding of the serialized block
block.serialize()
Returns the RLP serialization of the block.
block.validate(blockchain, cb)
Validates the entire block. Returns a string
to the callback if block is invalid
blockchain
- an instance of theBlockchain
cb
- the callback
block.validateUncles(blockchain, cb)
Validates the uncles that are in the block if any. Returns a string
to the callback if uncles are invalid
blockchain
- an instance of theBlockchain
cb
- the callback
block.validateTransactions()
Validates all of the transactions in the block. Returns a Boolean
block.validateTransactionsTrie()
Validates the transaction trie. Returns a Boolean
block.isGenesis()
Returns a Boolean
determining if the block is a genesis block
block.setGenesisParams()
Sets the parameters of the block to the genesis block.
block.toJSON([label=false])
Returns the block as a JSON object.
label
- ABoolean
. If true returns an JSON object with properties corresponding to the block properties if false it just returns a JSON array.
Blockheader
A object that repersents the block header.
- file - lib/blockheader.js
Blockheader
Properties
parentHash
- the blocks' parnet's hashuncleHash
- sha3(rlp_encode(uncle_list))coinbase
- the miner addressstateRoot
- The root of a Merkle Patricia treetransactionTrie
- the root of a Trie containing the transactionsreceiptTrie
- the root of a Trie containing the transaction Recieptbloom
difficulty
number
- the heightgasLimit
gasUsed
timestamp
extraData
raw
- anArray
ofBuffers
forming the raw header
Blockheader
Methods
blockheader.validate(blockchain, [height], cb)
Validates the entire block headers
blockchain
- blockChain the blockchain that this block is validating againstheight
if this is an uncle header, this is the height of the block that is including itcb
the callback function
blockheader.validateDifficulty()
Validates the difficutly returning a Boolean
blockheader.validateGasLimit()
Validates the gasLimit, returning a Boolean
blockheader.canonicalGasLimit(parentBlock)
Returns the canonical gas limit of the block
parentBlock
- the parentBlock
of the header
blockheader.canonicalDifficulty(parentBlock)
Returns the canoncical difficulty of the block
parentBlock
- the parentBlock
of the header
blockheader.hash()
Returns the sha3 hash of the blockheader