blockchain

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: GPL-3.0 Imports: 4 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 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

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

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

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

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

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

GetGenesisHeaderHash returns the genesis block header hash

func (*MetaChain) GetLocalHeight

func (mc *MetaChain) GetLocalHeight() int64

GetLocalHeight returns the height of the local chain

func (*MetaChain) GetNetworkHeight

func (mc *MetaChain) GetNetworkHeight() int64

GetNetworkHeight sets the percieved height of the network chain

func (*MetaChain) HasBadBlock

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) PutBadBlock

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

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

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

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

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

SetGenesisHeaderHash returns the genesis block header hash

func (*MetaChain) SetLocalHeight

func (mc *MetaChain) SetLocalHeight(height int64)

SetLocalHeight sets the height of the local chain

func (*MetaChain) SetNetworkHeight

func (mc *MetaChain) SetNetworkHeight(height int64)

SetNetworkHeight sets the percieved height of the network chain

Jump to

Keyboard shortcuts

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