blockchain

package
v0.29.3 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2022 License: LGPL-3.0 Imports: 44 Imported by: 17

Documentation

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
	StoreToIpfsThreshold          = 1 - fee.StoreToIpfsFeeCoef
)
View Source
const (
	OfflineVotesCacheLength = 10
)

Variables

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

Functions

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 BuildTxWithFeeEstimating added in v0.28.4

func BuildTxWithFeeEstimating(state *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 NewTiming

func NewTiming(conf *config.ValidationConfig) *timing

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, upgrader *upgrade.Upgrader) *Blockchain

func (*Blockchain) AddBlock

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

func (*Blockchain) AddHeaderUnsafe added in v0.27.3

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

func (*Blockchain) AtomicSwitchToPreliminary

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

func (*Blockchain) CoinbaseShard added in v0.27.3

func (chain *Blockchain) CoinbaseShard() (common.ShardId, 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) GenesisInfo added in v0.23.0

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

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) MinimalShard added in v0.27.3

func (chain *Blockchain) MinimalShard(appState *appstate.AppState) common.ShardId

func (*Blockchain) ModifiedCoinbaseShard added in v0.27.3

func (chain *Blockchain) ModifiedCoinbaseShard() (common.ShardId, error)

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) types.TotalValidationResult)

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) ReadPreliminaryConsensusVersion added in v0.23.0

func (chain *Blockchain) ReadPreliminaryConsensusVersion() uint32

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) RemovePreliminaryConsensusVersion added in v0.23.0

func (chain *Blockchain) RemovePreliminaryConsensusVersion()

func (*Blockchain) RemovePreliminaryHead

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

func (*Blockchain) RemovePreliminaryIntermediateGenesis added in v0.23.0

func (chain *Blockchain) RemovePreliminaryIntermediateGenesis()

func (*Blockchain) ResetTo

func (chain *Blockchain) ResetTo(height uint64) (revertedTxs []*types.Transaction, err error)

func (*Blockchain) Round

func (chain *Blockchain) Round() uint64

func (*Blockchain) ShardsNum added in v0.27.3

func (chain *Blockchain) ShardsNum() uint32

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, statsCollector collector.StatsCollector) (*blockInsertionResult, error)

func (*Blockchain) ValidateBlockCert

func (chain *Blockchain) ValidateBlockCert(prevBlock *types.Header, block *types.Header, cert *types.BlockCert, validatorsCache *validators.ValidatorsCache, pubKeyToAddrCache map[string]common.Address) (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) WritePreliminaryConsensusVersion added in v0.23.0

func (chain *Blockchain) WritePreliminaryConsensusVersion(ver uint32)

func (*Blockchain) WritePreliminaryIntermediateGenesis added in v0.23.0

func (chain *Blockchain) WritePreliminaryIntermediateGenesis(height uint64)

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) PushValidators added in v0.28.1

func (dt *OfflineDetector) PushValidators(round uint64, step uint8, stepValidators *validators.StepValidators)

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) AddTx added in v0.27.3

func (chain *TestBlockchain) AddTx(tx *types.Transaction) error

func (*TestBlockchain) Bus added in v0.27.3

func (chain *TestBlockchain) Bus() eventbus.Bus

func (*TestBlockchain) CommitState added in v0.27.3

func (chain *TestBlockchain) CommitState() *TestBlockchain

func (*TestBlockchain) Copy

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

func (*TestBlockchain) GenerateBlocks

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

func (*TestBlockchain) GenerateEmptyBlocks

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

func (*TestBlockchain) SecStore added in v0.27.3

func (chain *TestBlockchain) SecStore() *secstore.SecStore

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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