blockchain

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2022 License: GPL-3.0 Imports: 13 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AreChainsEqual

func AreChainsEqual(ch1 *Chain, head1 common.Hash, ch2 *Chain, head2 common.Hash) (bool, string)

AreChainsEqual returns whehter two chains are the same.

func AssertChainsEqual

func AssertChainsEqual(assert *assert.Assertions, ch1 *Chain, head1 common.Hash, ch2 *Chain, head2 common.Hash)

AssertChainsEqual asserts that two chains are the same.

func AssertChainsNotEqual

func AssertChainsNotEqual(assert *assert.Assertions, ch1 *Chain, head1 common.Hash, ch2 *Chain, head2 common.Hash)

AssertChainsNotEqual asserts that two chains are not the same.

Types

type BlockByHeightIndexEntry

type BlockByHeightIndexEntry struct {
	Blocks []common.Hash
}

type Chain

type Chain struct {
	ChainID string
	// contains filtered or unexported fields
}

Chain represents the blockchain and also is the interface to underlying store.

func CreateTestChain

func CreateTestChain() *Chain

CreateTestChain creates a chain for testing.

func CreateTestChainByBlocks

func CreateTestChainByBlocks(pairs []string) *Chain

CreateTestChainByBlocks creates a chain with given string slice in format:

[block1_hash, block1_parent_hash, block2_hash, block1_parent_hash, ...]

func NewChain

func NewChain(chainID string, store store.Store, root *core.Block) *Chain

NewChain creates a new Chain instance.

func (*Chain) AddBlock

func (ch *Chain) AddBlock(block *core.Block) (*core.ExtendedBlock, error)

AddBlock adds a block to the chain and underlying store

func (*Chain) AddBlockByHeightIndex

func (ch *Chain) AddBlockByHeightIndex(height uint64, block common.Hash)

func (*Chain) AddSnapshotRoot

func (ch *Chain) AddSnapshotRoot(block *core.Block) (*core.ExtendedBlock, error)

AddSnapshotRoot adds the root block of the chain

func (*Chain) AddTxReceipt

func (ch *Chain) AddTxReceipt(tx types.Tx, logs []*types.Log, evmRet common.Bytes,
	contractAddr common.Address, gasUsed uint64, evmErr error)

AddTxReceipt adds transaction receipt.

func (*Chain) AddTxsToIndex

func (ch *Chain) AddTxsToIndex(block *core.ExtendedBlock, force bool)

AddTxsToIndex adds transactions in given block to index.

func (*Chain) AddVoteToIndex

func (ch *Chain) AddVoteToIndex(vote core.Vote)

AddVoteToIndex adds a vote to index.

func (*Chain) CommitBlock

func (ch *Chain) CommitBlock(hash common.Hash)

func (*Chain) FinalizePreviousBlocks

func (ch *Chain) FinalizePreviousBlocks(hash common.Hash) error

func (*Chain) FindBlock

func (ch *Chain) FindBlock(hash common.Hash) (*core.ExtendedBlock, error)

FindBlock tries to retrieve a block by hash.

func (*Chain) FindBlocksByHeight

func (ch *Chain) FindBlocksByHeight(height uint64) []*core.ExtendedBlock

FindBlocksByHeight tries to retrieve blocks by height.

func (*Chain) FindTxByHash

func (ch *Chain) FindTxByHash(hash common.Hash) (tx common.Bytes, block *core.ExtendedBlock, founded bool)

FindTxByHash looks up transaction by hash and additionally returns the containing block.

func (*Chain) FindTxReceiptByHash

func (ch *Chain) FindTxReceiptByHash(hash common.Hash) (*TxReceiptEntry, bool)

FindTxReceiptByHash looks up transaction receipt by hash.

func (*Chain) FindVotesByHash

func (ch *Chain) FindVotesByHash(hash common.Hash) *core.VoteSet

FindVotesByHash looks up votes by hash.

func (*Chain) FixBlockIndex

func (ch *Chain) FixBlockIndex(block *core.ExtendedBlock)

FixBlockIndex fixes index for given block.

func (*Chain) FixMissingChildren

func (ch *Chain) FixMissingChildren(block *core.ExtendedBlock)

FixMissingChildren removes dead links to missing children blocks.

func (*Chain) IsDescendant

func (ch *Chain) IsDescendant(ascendantHash common.Hash, descendantHash common.Hash) bool

IsDescendant determines whether one block is the ascendant of another block.

func (*Chain) IsOrphan

func (ch *Chain) IsOrphan(block *core.Block) bool

func (*Chain) MarkBlockHasValidatorUpdate

func (ch *Chain) MarkBlockHasValidatorUpdate(hash common.Hash) *core.ExtendedBlock

func (*Chain) MarkBlockInvalid

func (ch *Chain) MarkBlockInvalid(hash common.Hash) *core.ExtendedBlock

func (*Chain) MarkBlockValid

func (ch *Chain) MarkBlockValid(hash common.Hash) *core.ExtendedBlock

func (*Chain) PrintBranch

func (ch *Chain) PrintBranch(hash common.Hash) string

PrintBranch return the string describing path from root to given leaf.

func (*Chain) RemoveVotesByHash

func (ch *Chain) RemoveVotesByHash(hash common.Hash)

RemoveVotesByHash removes votes for givin block.

func (*Chain) Root

func (ch *Chain) Root() *core.ExtendedBlock

Root returns the root block

func (*Chain) SaveBlock

func (ch *Chain) SaveBlock(block *core.ExtendedBlock) error

type TxIndexEntry

type TxIndexEntry struct {
	BlockHash   common.Hash
	BlockHeight uint64
	Index       uint64
}

TxIndexEntry is a positional metadata to help looking up a transaction given only its hash.

type TxReceiptEntry

type TxReceiptEntry struct {
	TxHash          common.Hash
	Logs            []*types.Log
	EvmRet          common.Bytes
	ContractAddress common.Address
	GasUsed         uint64
	EvmErr          string
}

TxReceiptEntry records smart contract Tx execution result.

Jump to

Keyboard shortcuts

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