blockchain

package
v1.0.41 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2019 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBadBlocksCacheNil = errors.New("badBlocksCache nil")

ErrBadBlocksCacheNil defines the error for using a nil cache for bad blocks

View Source
var ErrHeaderUnitNil = errors.New("header unit nil")

ErrHeaderUnitNil defines the error for using a nil storage unit for block headers

View Source
var ErrNilAppStatusHandler = errors.New("nil AppStatusHandler")

ErrNilAppStatusHandler defines the error for setting a nil AppStatusHandler

View Source
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 added in v1.0.3

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 added in v1.0.3

func (bc *BlockChain) GetCurrentBlockBody() data.BodyHandler

GetCurrentBlockBody returns the tx block body pointer

func (*BlockChain) GetCurrentBlockHeader added in v1.0.3

func (bc *BlockChain) GetCurrentBlockHeader() data.HeaderHandler

GetCurrentBlockHeader returns current block header pointer

func (*BlockChain) GetCurrentBlockHeaderHash added in v1.0.3

func (bc *BlockChain) GetCurrentBlockHeaderHash() []byte

GetCurrentBlockHeaderHash returns the current block header hash

func (*BlockChain) GetGenesisHeader added in v1.0.3

func (bc *BlockChain) GetGenesisHeader() data.HeaderHandler

GetGenesisHeader returns the genesis block header pointer

func (*BlockChain) GetGenesisHeaderHash added in v1.0.3

func (bc *BlockChain) GetGenesisHeaderHash() []byte

GetGenesisHeaderHash returns the genesis block header hash

func (*BlockChain) GetLocalHeight added in v1.0.3

func (bc *BlockChain) GetLocalHeight() int64

GetLocalHeight returns the height of the local chain

func (*BlockChain) GetNetworkHeight added in v1.0.3

func (bc *BlockChain) GetNetworkHeight() int64

GetNetworkHeight sets the perceived height of the network chain

func (*BlockChain) HasBadBlock added in v1.0.3

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) IsInterfaceNil added in v1.0.16

func (bc *BlockChain) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*BlockChain) PutBadBlock added in v1.0.3

func (bc *BlockChain) PutBadBlock(blockHash []byte)

PutBadBlock adds the given serialized block to the bad block cache, blacklisting it

func (*BlockChain) SetAppStatusHandler added in v1.0.12

func (bc *BlockChain) SetAppStatusHandler(ash core.AppStatusHandler) error

SetAppStatusHandler will set the AppStatusHandler which will be used for monitoring

func (*BlockChain) SetCurrentBlockBody added in v1.0.3

func (bc *BlockChain) SetCurrentBlockBody(body data.BodyHandler) error

SetCurrentBlockBody sets the tx block body pointer

func (*BlockChain) SetCurrentBlockHeader added in v1.0.3

func (bc *BlockChain) SetCurrentBlockHeader(header data.HeaderHandler) error

SetCurrentBlockHeader sets current block header pointer

func (*BlockChain) SetCurrentBlockHeaderHash added in v1.0.3

func (bc *BlockChain) SetCurrentBlockHeaderHash(hash []byte)

SetCurrentBlockHeaderHash returns the current block header hash

func (*BlockChain) SetGenesisHeader added in v1.0.3

func (bc *BlockChain) SetGenesisHeader(genesisBlock data.HeaderHandler) error

SetGenesisHeader sets the genesis block header pointer

func (*BlockChain) SetGenesisHeaderHash added in v1.0.3

func (bc *BlockChain) SetGenesisHeaderHash(hash []byte)

SetGenesisHeaderHash sets the genesis block header hash

func (*BlockChain) SetLocalHeight added in v1.0.3

func (bc *BlockChain) SetLocalHeight(height int64)

SetLocalHeight sets the height of the local chain

func (*BlockChain) SetNetworkHeight added in v1.0.3

func (bc *BlockChain) SetNetworkHeight(height int64)

SetNetworkHeight sets the perceived height of the network chain

type MetaChain added in v1.0.3

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

func NewMetaChain(
	badBlocksCache storage.Cacher,
) (*MetaChain, error)

NewMetaChain will initialize a new metachain instance

func (*MetaChain) GetCurrentBlockBody added in v1.0.3

func (mc *MetaChain) GetCurrentBlockBody() data.BodyHandler

GetCurrentBlockBody returns the block body pointer

func (*MetaChain) GetCurrentBlockHeader added in v1.0.3

func (mc *MetaChain) GetCurrentBlockHeader() data.HeaderHandler

GetCurrentBlockHeader returns current block header pointer

func (*MetaChain) GetCurrentBlockHeaderHash added in v1.0.3

func (mc *MetaChain) GetCurrentBlockHeaderHash() []byte

GetCurrentBlockHeaderHash returns the current block header hash

func (*MetaChain) GetGenesisHeader added in v1.0.3

func (mc *MetaChain) GetGenesisHeader() data.HeaderHandler

GetGenesisHeader returns the genesis block header pointer

func (*MetaChain) GetGenesisHeaderHash added in v1.0.3

func (mc *MetaChain) GetGenesisHeaderHash() []byte

GetGenesisHeaderHash returns the genesis block header hash

func (*MetaChain) GetLocalHeight added in v1.0.3

func (mc *MetaChain) GetLocalHeight() int64

GetLocalHeight returns the height of the local chain

func (*MetaChain) GetNetworkHeight added in v1.0.3

func (mc *MetaChain) GetNetworkHeight() int64

GetNetworkHeight sets the perceived height of the network chain

func (*MetaChain) HasBadBlock added in v1.0.3

func (mc *MetaChain) HasBadBlock(blockHash []byte) bool

HasBadBlock returns true if the provided hash is blacklisted as a bad block, or false otherwise

func (*MetaChain) IsInterfaceNil added in v1.0.16

func (mc *MetaChain) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*MetaChain) PutBadBlock added in v1.0.3

func (mc *MetaChain) PutBadBlock(blockHash []byte)

PutBadBlock adds the given serialized block to the bad block cache, blacklisting it

func (*MetaChain) SetAppStatusHandler added in v1.0.12

func (mc *MetaChain) SetAppStatusHandler(ash core.AppStatusHandler) error

SetAppStatusHandler will set the AppStatusHandler which will be used for monitoring

func (*MetaChain) SetCurrentBlockBody added in v1.0.3

func (mc *MetaChain) SetCurrentBlockBody(body data.BodyHandler) error

SetCurrentBlockBody sets the block body pointer

func (*MetaChain) SetCurrentBlockHeader added in v1.0.3

func (mc *MetaChain) SetCurrentBlockHeader(header data.HeaderHandler) error

SetCurrentBlockHeader sets current block header pointer

func (*MetaChain) SetCurrentBlockHeaderHash added in v1.0.3

func (mc *MetaChain) SetCurrentBlockHeaderHash(hash []byte)

SetCurrentBlockHeaderHash returns the current block header hash

func (*MetaChain) SetGenesisHeader added in v1.0.3

func (mc *MetaChain) SetGenesisHeader(header data.HeaderHandler) error

SetGenesisHeader returns the genesis block header pointer

func (*MetaChain) SetGenesisHeaderHash added in v1.0.3

func (mc *MetaChain) SetGenesisHeaderHash(headerHash []byte)

SetGenesisHeaderHash returns the genesis block header hash

func (*MetaChain) SetLocalHeight added in v1.0.3

func (mc *MetaChain) SetLocalHeight(height int64)

SetLocalHeight sets the height of the local chain

func (*MetaChain) SetNetworkHeight added in v1.0.3

func (mc *MetaChain) SetNetworkHeight(height int64)

SetNetworkHeight sets the perceived height of the network chain

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL