blockchain

package
v0.22.2-rc.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2020 License: LGPL-3.0 Imports: 48 Imported by: 17

Documentation

Overview

Package blockchain generated by go-bindata.// sources: stategen.out

Index

Constants

View Source
const (
	Mainnet types.Network = 0x0
	Testnet types.Network = 0x1
)
View Source
const (
	ProposerRole            uint8 = 0x1
	EmptyBlockTimeIncrement       = time.Second * 20
	MaxFutureBlockOffset          = time.Minute * 2
	MinBlockDelay                 = time.Second * 10
)
View Source
const (
	OfflineVotesCacheLength = 10
)

Variables

View Source
var (
	MaxHash             *big.Float
	ParentHashIsInvalid = errors.New("parentHash is invalid")
	BlockInsertionErr   = errors.New("can't insert block")
)

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo added in v0.20.0

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func BuildTx

func BuildTx(appState *appstate.AppState, from common.Address, to *common.Address, txType types.TxType,
	amount decimal.Decimal, maxFee decimal.Decimal, tips decimal.Decimal, nonce uint32, epoch uint16,
	payload []byte) *types.Transaction

func ConvertToFloat

func ConvertToFloat(amount *big.Int) decimal.Decimal

func ConvertToInt

func ConvertToInt(amount decimal.Decimal) *big.Int

func MustAsset added in v0.20.0

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func NewTiming

func NewTiming(conf *config.ValidationConfig) *timing

func RestoreAsset added in v0.20.0

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets added in v0.20.0

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

Types

type Blockchain

type Blockchain struct {
	Head            *types.Header
	PreliminaryHead *types.Header
	// contains filtered or unexported fields
}

func NewBlockchain

func NewBlockchain(config *config.Config, db dbm.DB, txpool *mempool.TxPool, appState *appstate.AppState,
	ipfs ipfs.Proxy, secStore *secstore.SecStore, bus eventbus.Bus, offlineDetector *OfflineDetector, keyStore *keystore.KeyStore, subManager *subscriptions.Manager) *Blockchain

func (*Blockchain) AddBlock

func (chain *Blockchain) AddBlock(block *types.Block, checkState *appstate.AppState,
	statsCollector collector.StatsCollector) error

func (*Blockchain) AddHeader

func (chain *Blockchain) AddHeader(header *types.Header) error

func (*Blockchain) ApplyTxOnState

func (chain *Blockchain) ApplyTxOnState(appState *appstate.AppState, vm vm.VM, tx *types.Transaction, statsCollector collector.StatsCollector) (*big.Int, *types.TxReceipt, error)

func (*Blockchain) AtomicSwitchToPreliminary

func (chain *Blockchain) AtomicSwitchToPreliminary(manifest *snapshot.Manifest) error

func (*Blockchain) Config

func (chain *Blockchain) Config() *config.Config

func (*Blockchain) EnsureIntegrity

func (chain *Blockchain) EnsureIntegrity() error

func (*Blockchain) GenerateEmptyBlock

func (chain *Blockchain) GenerateEmptyBlock() *types.Block

func (*Blockchain) GenerateGenesis

func (chain *Blockchain) GenerateGenesis(network types.Network) (*types.Block, error)

func (*Blockchain) Genesis

func (chain *Blockchain) Genesis() *types.Header

func (*Blockchain) GetBlock

func (chain *Blockchain) GetBlock(hash common.Hash) *types.Block

func (*Blockchain) GetBlockByHeight

func (chain *Blockchain) GetBlockByHeight(height uint64) *types.Block

func (*Blockchain) GetBlockHeaderByHeight

func (chain *Blockchain) GetBlockHeaderByHeight(height uint64) *types.Header

func (*Blockchain) GetBlockWithRetry

func (chain *Blockchain) GetBlockWithRetry(hash common.Hash) *types.Block

func (*Blockchain) GetCertificate

func (chain *Blockchain) GetCertificate(hash common.Hash) *types.BlockCert

func (*Blockchain) GetCommitteeSize

func (chain *Blockchain) GetCommitteeSize(vc *validators.ValidatorsCache, final bool) int

func (*Blockchain) GetCommitteeVotesThreshold

func (chain *Blockchain) GetCommitteeVotesThreshold(vc *validators.ValidatorsCache, final bool) int

func (*Blockchain) GetGasCost added in v0.22.0

func (chain *Blockchain) GetGasCost(appState *appstate.AppState, gasUsed uint64) *big.Int

func (*Blockchain) GetHead

func (chain *Blockchain) GetHead() *types.Header

func (*Blockchain) GetIdentityDiff

func (chain *Blockchain) GetIdentityDiff(height uint64) *state.IdentityStateDiff

func (*Blockchain) GetProposerSortition

func (chain *Blockchain) GetProposerSortition() (bool, []byte)

func (*Blockchain) GetReceipt added in v0.22.0

func (chain *Blockchain) GetReceipt(hash common.Hash) *types.TxReceipt

func (*Blockchain) GetTopBlockHashes

func (chain *Blockchain) GetTopBlockHashes(count int) []common.Hash

func (*Blockchain) GetTx

func (chain *Blockchain) GetTx(hash common.Hash) (*types.Transaction, *types.TransactionIndex)

func (*Blockchain) GetTxIndex

func (chain *Blockchain) GetTxIndex(hash common.Hash) *types.TransactionIndex

func (*Blockchain) Indexer added in v0.19.5

func (chain *Blockchain) Indexer() *indexer

func (*Blockchain) InitializeChain

func (chain *Blockchain) InitializeChain() error

func (*Blockchain) IsPermanentCert

func (chain *Blockchain) IsPermanentCert(header *types.Header) bool

func (*Blockchain) Network

func (chain *Blockchain) Network() types.Network

func (*Blockchain) ProposeBlock

func (chain *Blockchain) ProposeBlock(proof []byte) *types.BlockProposal

func (*Blockchain) ProvideApplyNewEpochFunc

func (chain *Blockchain) ProvideApplyNewEpochFunc(fn func(height uint64, appState *appstate.AppState, collector collector.StatsCollector) (int, *types.ValidationResults, bool))

func (*Blockchain) ReadBlockForForkedPeer

func (chain *Blockchain) ReadBlockForForkedPeer(blocks []common.Hash) []types.BlockBundle

func (*Blockchain) ReadEvents added in v0.22.0

func (chain *Blockchain) ReadEvents(contract common.Address) []*types.SavedEvent

func (*Blockchain) ReadPreliminaryHead

func (chain *Blockchain) ReadPreliminaryHead() *types.Header

func (*Blockchain) ReadSnapshotManifest

func (chain *Blockchain) ReadSnapshotManifest() *snapshot.Manifest

func (*Blockchain) ReadTotalBurntCoins

func (chain *Blockchain) ReadTotalBurntCoins() []*types.BurntCoins

func (*Blockchain) ReadTxs

func (chain *Blockchain) ReadTxs(address common.Address, count int, token []byte) ([]*types.SavedTransaction, []byte)

func (*Blockchain) RemovePreliminaryHead

func (chain *Blockchain) RemovePreliminaryHead(batch dbm.Batch)

func (*Blockchain) ResetTo

func (chain *Blockchain) ResetTo(height uint64) error

func (*Blockchain) Round

func (chain *Blockchain) Round() uint64

func (*Blockchain) StartSync

func (chain *Blockchain) StartSync()

func (*Blockchain) StopSync

func (chain *Blockchain) StopSync()

func (*Blockchain) ValidateBlock

func (chain *Blockchain) ValidateBlock(block *types.Block, checkState *appstate.AppState) error

func (*Blockchain) ValidateBlockCert

func (chain *Blockchain) ValidateBlockCert(prevBlock *types.Header, block *types.Header, cert *types.BlockCert, validatorsCache *validators.ValidatorsCache) (err error)

func (*Blockchain) ValidateBlockCertOnHead

func (chain *Blockchain) ValidateBlockCertOnHead(block *types.Header, cert *types.BlockCert) error

func (*Blockchain) ValidateHeader

func (chain *Blockchain) ValidateHeader(header, prevBlock *types.Header) error

func (*Blockchain) ValidateProposerProof

func (chain *Blockchain) ValidateProposerProof(proof []byte, pubKeyData []byte) error

func (*Blockchain) ValidateSubChain

func (chain *Blockchain) ValidateSubChain(startHeight uint64, blocks []types.BlockBundle) error

func (*Blockchain) WriteCertificate

func (chain *Blockchain) WriteCertificate(hash common.Hash, cert *types.BlockCert, persistent bool)

func (*Blockchain) WriteFinalConsensus

func (chain *Blockchain) WriteFinalConsensus(hash common.Hash)

func (*Blockchain) WriteIdentityStateDiff

func (chain *Blockchain) WriteIdentityStateDiff(height uint64, diff *state.IdentityStateDiff)

func (*Blockchain) WriteTxIndex

func (chain *Blockchain) WriteTxIndex(hash common.Hash, txs types.Transactions)

func (*Blockchain) WriteTxReceipts added in v0.22.0

func (chain *Blockchain) WriteTxReceipts(cid []byte, receipts types.TxReceipts)

type OfflineDetector

type OfflineDetector struct {
	// contains filtered or unexported fields
}

func NewOfflineDetector

func NewOfflineDetector(config *config.Config, db dbm.DB, appState *appstate.AppState, secStore *secstore.SecStore, bus eventbus.Bus) *OfflineDetector

func (*OfflineDetector) GetActivityMap

func (dt *OfflineDetector) GetActivityMap() map[common.Address]time.Time

func (*OfflineDetector) ProcessVote

func (dt *OfflineDetector) ProcessVote(vote *types.Vote)

func (*OfflineDetector) ProposeOffline

func (dt *OfflineDetector) ProposeOffline(head *types.Header) (*common.Address, types.BlockFlag)

func (*OfflineDetector) Start

func (dt *OfflineDetector) Start(head *types.Header)

func (*OfflineDetector) ValidateBlock

func (dt *OfflineDetector) ValidateBlock(head *types.Header, block *types.Block) error

func (*OfflineDetector) VoteForOffline

func (dt *OfflineDetector) VoteForOffline(block *types.Block) bool

type TestBlockchain

type TestBlockchain struct {
	*Blockchain
	// contains filtered or unexported fields
}

func NewCustomTestBlockchain

func NewCustomTestBlockchain(blocksCount int, emptyBlocksCount int, key *ecdsa.PrivateKey) (*TestBlockchain, *appstate.AppState)

func NewCustomTestBlockchainWithConfig

func NewCustomTestBlockchainWithConfig(blocksCount int, emptyBlocksCount int, key *ecdsa.PrivateKey, cfg *config.Config) (*TestBlockchain, *appstate.AppState)

func NewTestBlockchainWithBlocks

func NewTestBlockchainWithBlocks(blocksCount int, emptyBlocksCount int) (*TestBlockchain, *appstate.AppState)

func NewTestBlockchainWithConfig

func NewTestBlockchainWithConfig(withIdentity bool, conf *config.ConsensusConf, valConf *config.ValidationConfig, alloc map[common.Address]config.GenesisAllocation, queueSlots int, executableSlots int, executableLimit int, queueLimit int) (*TestBlockchain, *appstate.AppState, *mempool.TxPool, *ecdsa.PrivateKey)

func (*TestBlockchain) Copy

func (chain *TestBlockchain) Copy() (*TestBlockchain, *appstate.AppState)

func (*TestBlockchain) GenerateBlocks

func (chain *TestBlockchain) GenerateBlocks(count int) *TestBlockchain

func (*TestBlockchain) GenerateEmptyBlocks

func (chain *TestBlockchain) GenerateEmptyBlocks(count int) *TestBlockchain

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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