Documentation
¶
Index ¶
- Variables
- func SetupGenesis(genesis *Genesis, chain *Chain) (*params.ChainConfig, state.Database, utils.Hash, error)
- type Chain
- type Config
- type Genesis
- type GenesisAccount
- type GenesisAlloc
- type Ledger
- func (l *Ledger) CheckLastBlock(genesis *types.Block) *types.Block
- func (l *Ledger) DeleteBlock(blockHash utils.Hash)
- func (l *Ledger) GetBlock(hash utils.Hash) *types.Block
- func (l *Ledger) GetBlockByHash(blockHash utils.Hash) *types.Block
- func (l *Ledger) GetBlockByHeight(height uint64) *types.Block
- func (l *Ledger) GetDB() db.Database
- func (l *Ledger) GetFutureBlock() types.Blocks
- func (l *Ledger) GetHeadBlockHash() utils.Hash
- func (l *Ledger) GetHeader(hash utils.Hash) *types.BlockHeader
- func (l *Ledger) GetReceipt(txHash utils.Hash) *types.Receipt
- func (l *Ledger) GetReceipts(blockHash utils.Hash) types.Receipts
- func (l *Ledger) GetTd(hash utils.Hash) *big.Int
- func (l *Ledger) GetTransactionByHash(txHash utils.Hash) *types.StorageTx
- func (l *Ledger) HasBlock(hash utils.Hash) bool
- func (l *Ledger) HasFutureBlock(hash utils.Hash) bool
- func (l *Ledger) HasHeader(hash utils.Hash, height uint64) bool
- func (l *Ledger) HasState(hash utils.Hash) bool
- func (l *Ledger) PutFutureBlock(block *types.Block) error
- func (l *Ledger) RemoveFutureBlock(hash utils.Hash)
- func (l *Ledger) ResetChain(genesis *types.Block)
- func (l *Ledger) RewindChain(height uint64)
- func (l *Ledger) WriteBlockAndReceipts(block *types.Block, receipts types.Receipts)
- func (l *Ledger) WriteBlockAndTd(block *types.Block, td *big.Int)
- func (l *Ledger) WriteLegitimateHashAndHeadBlockHash(height uint64, hash utils.Hash)
- func (l *Ledger) WriteTd(hash utils.Hash, td *big.Int)
Constants ¶
This section is empty.
Variables ¶
var (
ErrNoGenesis = errors.New("Genesis not found in chain")
)
Common errors.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config represents cache config
type Genesis ¶
type Genesis struct { Config *params.ChainConfig `json:"config"` Nonce uint64 `json:"nonce"` Timestamp uint64 `json:"timestamp"` ExtraData []byte `json:"extraData"` GasLimit uint64 `json:"gasLimit" ` Difficulty *big.Int `json:"difficulty" ` Mixhash utils.Hash `json:"mixHash"` Miner utils.Address `json:"miner"` Height uint64 `json:"height"` GasUsed uint64 `json:"gasUsed"` PreviousHash utils.Hash `json:"previousHash"` Alloc GenesisAlloc `json:"alloc"` }
Genesis specifies the header fields, state of a genesis block.
func DefaultGenesis ¶
func DefaultGenesis() *Genesis
DefaultGenesis returns the nurans main net genesis block.
func (*Genesis) Commit ¶
Commit writes the block and state of a genesis specification to the database.
func (Genesis) MarshalJSON ¶
func (*Genesis) UnmarshalJSON ¶
type GenesisAccount ¶
type GenesisAccount struct { Code []byte `json:"code,omitempty"` Storage map[utils.Hash]utils.Hash `json:"storage,omitempty"` Balance math.HexOrDecimal256 `json:"balance" gencodec:"required"` Nonce uint64 `json:"nonce,omitempty"` }
GenesisAccount is an account in the state of the genesis block.
type GenesisAlloc ¶
type GenesisAlloc map[utils.Address]GenesisAccount
GenesisAlloc specifies the initial state that is part of the genesis block.
type Ledger ¶
type Ledger struct {
// contains filtered or unexported fields
}
Ledger represents the ledger in blockchain
func (*Ledger) CheckLastBlock ¶
CheckLastBlock check the last block is right or reset chain with genesis block.
func (*Ledger) DeleteBlock ¶
func (*Ledger) GetBlockByHash ¶
GetBlockByHash retrieves a block from the database by hash, caching it if found.
func (*Ledger) GetBlockByHeight ¶
GetBlockByHeight retrieves a block from the database by height.
func (*Ledger) GetFutureBlock ¶
GetFutureBlock get all future from ledger cache .
func (*Ledger) GetHeadBlockHash ¶
GetHeadBlockHash get the last block hash
func (*Ledger) GetHeader ¶
func (l *Ledger) GetHeader(hash utils.Hash) *types.BlockHeader
GetHeader retrieves a header from the database by hash,
func (*Ledger) GetReceipt ¶
GetReceipt return Receipt by transaction hash.
func (*Ledger) GetReceipts ¶
GetReceipts return Receipts by block hash.
func (*Ledger) GetTransactionByHash ¶
GetTransactionByHash retrieves a transaction from the database by hash, caching it if found.
func (*Ledger) HasFutureBlock ¶
HasFutureBlock checks if a future block in cache.
func (*Ledger) PutFutureBlock ¶
PutFutureBlock put a block in future cache
func (*Ledger) RemoveFutureBlock ¶
RemoveFutureBlock remove future block by hash
func (*Ledger) ResetChain ¶
ResetChain reset chain with genesis block
func (*Ledger) RewindChain ¶
RewindChain rewind the chain, deleting all block
func (*Ledger) WriteBlockAndReceipts ¶
func (*Ledger) WriteBlockAndTd ¶
WriteBlockAndTd serializes a block and td into the database, header and txs separately.
func (*Ledger) WriteLegitimateHashAndHeadBlockHash ¶
WriteLegitimateHashAndHeadBlockHash write the Legitimate chain