Documentation
¶
Index ¶
- Variables
- type BlockChain
- func (bc *BlockChain) GetCurrentBlockBody() data.BodyHandler
- func (bc *BlockChain) GetCurrentBlockHeader() data.HeaderHandler
- func (bc *BlockChain) GetCurrentBlockHeaderHash() []byte
- func (bc *BlockChain) GetGenesisHeader() data.HeaderHandler
- func (bc *BlockChain) GetGenesisHeaderHash() []byte
- func (bc *BlockChain) GetLocalHeight() int64
- func (bc *BlockChain) GetNetworkHeight() int64
- func (bc *BlockChain) HasBadBlock(blockHash []byte) bool
- func (bc *BlockChain) PutBadBlock(blockHash []byte)
- func (bc *BlockChain) SetCurrentBlockBody(body data.BodyHandler) error
- func (bc *BlockChain) SetCurrentBlockHeader(header data.HeaderHandler) error
- func (bc *BlockChain) SetCurrentBlockHeaderHash(hash []byte)
- func (bc *BlockChain) SetGenesisHeader(genesisBlock data.HeaderHandler) error
- func (bc *BlockChain) SetGenesisHeaderHash(hash []byte)
- func (bc *BlockChain) SetLocalHeight(height int64)
- func (bc *BlockChain) SetNetworkHeight(height int64)
- type MetaChain
- func (mc *MetaChain) GetCurrentBlockBody() data.BodyHandler
- func (mc *MetaChain) GetCurrentBlockHeader() data.HeaderHandler
- func (mc *MetaChain) GetCurrentBlockHeaderHash() []byte
- func (mc *MetaChain) GetGenesisHeader() data.HeaderHandler
- func (mc *MetaChain) GetGenesisHeaderHash() []byte
- func (mc *MetaChain) GetLocalHeight() int64
- func (mc *MetaChain) GetNetworkHeight() int64
- func (mc *MetaChain) HasBadBlock(blockHash []byte) bool
- func (mc *MetaChain) PutBadBlock(blockHash []byte)
- func (mc *MetaChain) SetCurrentBlockBody(body data.BodyHandler) error
- func (mc *MetaChain) SetCurrentBlockHeader(header data.HeaderHandler) error
- func (mc *MetaChain) SetCurrentBlockHeaderHash(hash []byte)
- func (mc *MetaChain) SetGenesisHeader(header data.HeaderHandler) error
- func (mc *MetaChain) SetGenesisHeaderHash(headerHash []byte)
- func (mc *MetaChain) SetLocalHeight(height int64)
- func (mc *MetaChain) SetNetworkHeight(height int64)
Constants ¶
This section is empty.
Variables ¶
var ErrBadBlocksCacheNil = errors.New("badBlocksCache nil")
ErrBadBlocksCacheNil defines the error for using a nil cache for bad blocks
var ErrHeaderUnitNil = errors.New("header unit nil")
ErrHeaderUnitNil defines the error for using a nil storage unit for block headers
var ErrWrongTypeInSet = errors.New("wrong type in setter")
ErrWrongTypeInSet defines the error for trying to set the wrong type
Functions ¶
This section is empty.
Types ¶
type BlockChain ¶
type BlockChain struct { GenesisHeader *block.Header // Genesis Block Header pointer CurrentBlockHeader *block.Header // Current Block Header pointer CurrentBlockBody block.Body // Current Block Body pointer // contains filtered or unexported fields }
BlockChain holds the block information for the current shard.
The BlockChain also holds pointers to the Genesis block header, the current block the height of the local chain and the perceived height of the chain in the network.
func NewBlockChain ¶
func NewBlockChain( badBlocksCache storage.Cacher, ) (*BlockChain, error)
NewBlockChain returns an initialized blockchain It uses a config file to setup it's supported storage units map
func (*BlockChain) GetCurrentBlockBody ¶
func (bc *BlockChain) GetCurrentBlockBody() data.BodyHandler
GetCurrentBlockBody returns the tx block body pointer
func (*BlockChain) GetCurrentBlockHeader ¶
func (bc *BlockChain) GetCurrentBlockHeader() data.HeaderHandler
GetCurrentBlockHeader returns current block header pointer
func (*BlockChain) GetCurrentBlockHeaderHash ¶
func (bc *BlockChain) GetCurrentBlockHeaderHash() []byte
GetCurrentBlockHeaderHash returns the current block header hash
func (*BlockChain) GetGenesisHeader ¶
func (bc *BlockChain) GetGenesisHeader() data.HeaderHandler
GetGenesisHeader returns the genesis block header pointer
func (*BlockChain) GetGenesisHeaderHash ¶
func (bc *BlockChain) GetGenesisHeaderHash() []byte
GetGenesisHeaderHash returns the genesis block header hash
func (*BlockChain) GetLocalHeight ¶
func (bc *BlockChain) GetLocalHeight() int64
GetLocalHeight returns the height of the local chain
func (*BlockChain) GetNetworkHeight ¶
func (bc *BlockChain) GetNetworkHeight() int64
GetNetworkHeight sets the percieved height of the network chain
func (*BlockChain) HasBadBlock ¶
func (bc *BlockChain) HasBadBlock(blockHash []byte) bool
HasBadBlock returns true if the provided hash is blacklisted as a bad block, or false otherwise
func (*BlockChain) PutBadBlock ¶
func (bc *BlockChain) PutBadBlock(blockHash []byte)
PutBadBlock adds the given serialized block to the bad block cache, blacklisting it
func (*BlockChain) SetCurrentBlockBody ¶
func (bc *BlockChain) SetCurrentBlockBody(body data.BodyHandler) error
SetCurrentBlockBody sets the tx block body pointer
func (*BlockChain) SetCurrentBlockHeader ¶
func (bc *BlockChain) SetCurrentBlockHeader(header data.HeaderHandler) error
SetCurrentBlockHeader sets current block header pointer
func (*BlockChain) SetCurrentBlockHeaderHash ¶
func (bc *BlockChain) SetCurrentBlockHeaderHash(hash []byte)
SetCurrentBlockHeaderHash returns the current block header hash
func (*BlockChain) SetGenesisHeader ¶
func (bc *BlockChain) SetGenesisHeader(genesisBlock data.HeaderHandler) error
SetGenesisHeader sets the genesis block header pointer
func (*BlockChain) SetGenesisHeaderHash ¶
func (bc *BlockChain) SetGenesisHeaderHash(hash []byte)
SetGenesisHeaderHash sets the genesis block header hash
func (*BlockChain) SetLocalHeight ¶
func (bc *BlockChain) SetLocalHeight(height int64)
SetLocalHeight sets the height of the local chain
func (*BlockChain) SetNetworkHeight ¶
func (bc *BlockChain) SetNetworkHeight(height int64)
SetNetworkHeight sets the percieved height of the network chain
type MetaChain ¶
type MetaChain struct { GenesisBlock *block.MetaBlock // Genesys Block pointer CurrentBlock *block.MetaBlock // Current Block pointer // contains filtered or unexported fields }
MetaChain holds the block information for the beacon chain
The MetaChain also holds pointers to the Genesis block, the current block the height of the local chain and the perceived height of the chain in the network.
func NewMetaChain ¶
NewMetaChain will initialize a new metachain instance
func (*MetaChain) GetCurrentBlockBody ¶
func (mc *MetaChain) GetCurrentBlockBody() data.BodyHandler
GetCurrentBlockBody returns the block body pointer
func (*MetaChain) GetCurrentBlockHeader ¶
func (mc *MetaChain) GetCurrentBlockHeader() data.HeaderHandler
GetCurrentBlockHeader returns current block header pointer
func (*MetaChain) GetCurrentBlockHeaderHash ¶
GetCurrentBlockHeaderHash returns the current block header hash
func (*MetaChain) GetGenesisHeader ¶
func (mc *MetaChain) GetGenesisHeader() data.HeaderHandler
GetGenesisHeader returns the genesis block header pointer
func (*MetaChain) GetGenesisHeaderHash ¶
GetGenesisHeaderHash returns the genesis block header hash
func (*MetaChain) GetLocalHeight ¶
GetLocalHeight returns the height of the local chain
func (*MetaChain) GetNetworkHeight ¶
GetNetworkHeight sets the percieved height of the network chain
func (*MetaChain) HasBadBlock ¶
HasBadBlock returns true if the provided hash is blacklisted as a bad block, or false otherwise
func (*MetaChain) PutBadBlock ¶
PutBadBlock adds the given serialized block to the bad block cache, blacklisting it
func (*MetaChain) SetCurrentBlockBody ¶
func (mc *MetaChain) SetCurrentBlockBody(body data.BodyHandler) error
SetCurrentBlockBody sets the block body pointer
func (*MetaChain) SetCurrentBlockHeader ¶
func (mc *MetaChain) SetCurrentBlockHeader(header data.HeaderHandler) error
SetCurrentBlockHeader sets current block header pointer
func (*MetaChain) SetCurrentBlockHeaderHash ¶
SetCurrentBlockHeaderHash returns the current block header hash
func (*MetaChain) SetGenesisHeader ¶
func (mc *MetaChain) SetGenesisHeader(header data.HeaderHandler) error
SetGenesisHeader returns the genesis block header pointer
func (*MetaChain) SetGenesisHeaderHash ¶
SetGenesisHeaderHash returns the genesis block header hash
func (*MetaChain) SetLocalHeight ¶
SetLocalHeight sets the height of the local chain
func (*MetaChain) SetNetworkHeight ¶
SetNetworkHeight sets the percieved height of the network chain