Documentation ¶
Index ¶
- Constants
- Variables
- func CanVerifyHeight(height uint32) bool
- func GetNextBlockSigner(height uint32, timestamp int64) ([]byte, []byte, pb.WinnerType, error)
- func GetNextMiningSigChainTxnHash(height uint32) (common.Uint256, pb.WinnerType, error)
- func GetPercentageByDuration(duration uint32) [7]float64
- func GetRewardByHeight(height uint32) (common.Fixed64, [7]common.Fixed64)
- func GetSwapRate() int64
- func HeaderCheck(header *block.Header, fastSync bool) error
- func NextBlockProposerCheck(header *block.Header) error
- func SignerCheck(header *block.Header) error
- func TimestampCheck(header *block.Header, soft bool) error
- func TransactionCheck(ctx context.Context, block *block.Block, fastSync bool) error
- func VerifyTransactionWithLedger(txn *transaction.Transaction, height uint32) error
- type BlockValidationState
- func (bvs *BlockValidationState) CleanSubmittedTransactions(txns []*transaction.Transaction) error
- func (bvs *BlockValidationState) Close()
- func (bvs *BlockValidationState) Commit()
- func (bvs *BlockValidationState) GetSubscribers(topic string) []string
- func (bvs *BlockValidationState) GetSubscribersWithMeta(topic string) map[string]string
- func (bvs *BlockValidationState) RefreshBlockValidationState(txns []*transaction.Transaction) map[common.Uint256]error
- func (bvs *BlockValidationState) Reset()
- func (bvs *BlockValidationState) VerifyTransactionWithBlock(txn *transaction.Transaction, height uint32) (e error)
- type Blockchain
- func (bc *Blockchain) AddBlock(block *block.Block, pruning, fastSync bool) error
- func (bc *Blockchain) AddHeader(header *block.Header, fastSync bool) error
- func (bc *Blockchain) GetHeader(hash common.Uint256) (*block.Header, error)
- func (bc *Blockchain) SaveBlock(block *block.Block, pruning, fastSync bool) error
- type BuiltinMining
- func (bm *BuiltinMining) BuildBlock(ctx context.Context, height uint32, chordID []byte, winnerHash common.Uint256, ...) (*block.Block, error)
- func (bm *BuiltinMining) CreateCoinbaseTransaction(TotalReward common.Fixed64, distributedRewardsPerRole [7]common.Fixed64, ...) *transaction.Transaction
- func (bm *BuiltinMining) SignBlock(b *block.Block, timestamp int64) error
- type ILedgerStore
- type Ledger
- func (l *Ledger) BlockInLedger(hash common.Uint256) bool
- func (l *Ledger) GetBlockWithHash(hash common.Uint256) (*block.Block, error)
- func (l *Ledger) GetBlockWithHeight(height uint32) (*block.Block, error)
- func (l *Ledger) GetLocalBlockChainHeight() uint32
- func (l *Ledger) GetTransactionWithHash(hash common.Uint256) (*transaction.Transaction, error)
- func (l *Ledger) IsDoubleSpend(Tx *transaction.Transaction) bool
- type Mining
- type TransactionArray
- type TxnCollection
- type TxnCollector
- type TxnSource
- type VBlock
Constants ¶
const ( TimestampToleranceFuture = config.ConsensusDuration / 4 TimestampTolerancePast = config.ConsensusDuration / 2 TimestampToleranceVariance = config.ConsensusDuration / 6 ProposingTimeTolerance = config.ConsensusDuration / 2 NumGenesisBlocks = 4 )
const (
MaxCollectableEntityNum = 20480
)
Variables ¶
Functions ¶
func CanVerifyHeight ¶
func GetNextBlockSigner ¶
GetNextBlockSigner gets the next block signer after block height at timestamp. Returns next signer's public key, chord ID, winner type, and error
func GetNextMiningSigChainTxnHash ¶
GetNextMiningSigChainTxnHash returns the winner hash and winner type of a block height using sigchain from PoR server.
func GetPercentageByDuration ¶
func GetSwapRate ¶
func GetSwapRate() int64
func NextBlockProposerCheck ¶
func SignerCheck ¶
func TransactionCheck ¶
func VerifyTransactionWithLedger ¶
func VerifyTransactionWithLedger(txn *transaction.Transaction, height uint32) error
VerifyTransactionWithLedger verifys a transaction with history transaction in ledger
Types ¶
type BlockValidationState ¶
func NewBlockValidationState ¶
func NewBlockValidationState() *BlockValidationState
func (*BlockValidationState) CleanSubmittedTransactions ¶
func (bvs *BlockValidationState) CleanSubmittedTransactions(txns []*transaction.Transaction) error
func (*BlockValidationState) Close ¶
func (bvs *BlockValidationState) Close()
func (*BlockValidationState) Commit ¶
func (bvs *BlockValidationState) Commit()
func (*BlockValidationState) GetSubscribers ¶
func (bvs *BlockValidationState) GetSubscribers(topic string) []string
func (*BlockValidationState) GetSubscribersWithMeta ¶
func (bvs *BlockValidationState) GetSubscribersWithMeta(topic string) map[string]string
func (*BlockValidationState) RefreshBlockValidationState ¶
func (bvs *BlockValidationState) RefreshBlockValidationState(txns []*transaction.Transaction) map[common.Uint256]error
func (*BlockValidationState) Reset ¶
func (bvs *BlockValidationState) Reset()
func (*BlockValidationState) VerifyTransactionWithBlock ¶
func (bvs *BlockValidationState) VerifyTransactionWithBlock(txn *transaction.Transaction, height uint32) (e error)
VerifyTransactionWithBlock verifies a transaction with current transaction pool in memory
type Blockchain ¶
type Blockchain struct { BlockHeight uint32 AssetID common.Uint256 BlockPersistTime map[common.Uint256]int64 // contains filtered or unexported fields }
func NewBlockchain ¶
func NewBlockchain(height uint32, asset common.Uint256) *Blockchain
func NewBlockchainWithGenesisBlock ¶
func NewBlockchainWithGenesisBlock(store ILedgerStore) (*Blockchain, error)
func (*Blockchain) AddBlock ¶
func (bc *Blockchain) AddBlock(block *block.Block, pruning, fastSync bool) error
func (*Blockchain) AddHeader ¶
func (bc *Blockchain) AddHeader(header *block.Header, fastSync bool) error
type BuiltinMining ¶
type BuiltinMining struct {
// contains filtered or unexported fields
}
func NewBuiltinMining ¶
func NewBuiltinMining(account *vault.Account, txnCollector *TxnCollector) *BuiltinMining
func (*BuiltinMining) BuildBlock ¶
func (*BuiltinMining) CreateCoinbaseTransaction ¶
func (bm *BuiltinMining) CreateCoinbaseTransaction(TotalReward common.Fixed64, distributedRewardsPerRole [7]common.Fixed64, height uint32) *transaction.Transaction
type ILedgerStore ¶
type ILedgerStore interface { SaveBlock(b *block.Block, pruning, fastSync bool) error GetBlock(hash common.Uint256) (*block.Block, error) GetBlockByHeight(height uint32) (*block.Block, error) GetBlockHash(height uint32) (common.Uint256, error) IsDoubleSpend(tx *transaction.Transaction) bool AddHeader(header *block.Header) error GetHeader(hash common.Uint256) (*block.Header, error) GetHeaderByHeight(height uint32) (*block.Header, error) GetTransaction(hash common.Uint256) (*transaction.Transaction, error) GetName_legacy(registrant []byte) (string, error) GetRegistrant(name string) ([]byte, uint32, error) GetRegistrant_legacy(name string) ([]byte, error) IsSubscribed(topic string, bucket uint32, subscriber []byte, identifier string) (bool, error) GetSubscription(topic string, bucket uint32, subscriber []byte, identifier string) (string, uint32, error) GetSubscribers(topic string, bucket, offset, limit uint32, subscriberHashPrefix []byte, ctx context.Context) ([]string, error) GetSubscribersWithMeta(topic string, bucket, offset, limit uint32, subscriberHashPrefix []byte, ctx context.Context) (map[string]string, error) GetSubscribersCount(topic string, bucket uint32, subscriberHashPrefix []byte, ctx context.Context) (int, error) GetID(publicKey []byte, height uint32) ([]byte, error) GetIDVersion(publicKey []byte) ([]byte, byte, error) GetBalance(addr common.Uint160) common.Fixed64 GetRDCBalance(addr common.Uint160) common.Fixed64 GetBalanceByAssetID(addr common.Uint160, assetID common.Uint256) common.Fixed64 GetNonce(addr common.Uint160) uint64 GetNanoPay(addr common.Uint160, recipient common.Uint160, nonce uint64) (common.Fixed64, uint32, error) GetCurrentBlockHash() common.Uint256 GetCurrentHeaderHash() common.Uint256 GetHeaderHeight() uint32 GetHeight() uint32 GetHeightByBlockHash(hash common.Uint256) (uint32, error) GetHeaderHashByHeight(height uint32) common.Uint256 GetHeaderWithCache(hash common.Uint256) (*block.Header, error) GetSigChainWithCache(hash common.Uint256) (*pb.SigChain, error) InitLedgerStoreWithGenesisBlock(genesisblock *block.Block) (uint32, error) GetDonation() (common.Fixed64, error) IsTxHashDuplicate(txhash common.Uint256) bool IsBlockInStore(hash common.Uint256) bool Rollback(b *block.Block) error GenerateStateRoot(ctx context.Context, b *block.Block, genesisBlockInitialized, needBeCommitted bool) (common.Uint256, error) GetAsset(assetID common.Uint256) (name, symbol string, totalSupply common.Fixed64, precision uint32, err error) GetDatabase() db.IStore ShouldFastSync(syncStopHeight uint32) bool GetSyncRootHeight() (uint32, error) GetFastSyncStateRoot() (common.Uint256, error) PrepareFastSync(fastSyncHeight uint32, fastSyncRootHash common.Uint256) error FastSyncDone(syncRootHash common.Uint256, fastSyncHeight uint32) error Close() }
ILedgerStore provides func with store package.
type Ledger ¶
type Ledger struct { Blockchain *Blockchain Store ILedgerStore }
var DefaultLedger *Ledger
func (*Ledger) BlockInLedger ¶
BlockInLedger checks if the block existed in ledger
func (*Ledger) GetBlockWithHash ¶
Get block with block hash.
func (*Ledger) GetBlockWithHeight ¶
Get Block With Height.
func (*Ledger) GetLocalBlockChainHeight ¶
Get local block chain height.
func (*Ledger) GetTransactionWithHash ¶
func (l *Ledger) GetTransactionWithHash(hash common.Uint256) (*transaction.Transaction, error)
Get transaction with hash.
func (*Ledger) IsDoubleSpend ¶
func (l *Ledger) IsDoubleSpend(Tx *transaction.Transaction) bool
double spend checking for transaction
type TransactionArray ¶
type TransactionArray []*transaction.Transaction
func (TransactionArray) Iterate ¶
func (iterable TransactionArray) Iterate(handler func(item *transaction.Transaction) error) error
type TxnCollection ¶
type TxnCollection struct {
// contains filtered or unexported fields
}
func NewTxnCollection ¶
func NewTxnCollection(txnLists map[common.Uint160][]*transaction.Transaction) *TxnCollection
func (*TxnCollection) Peek ¶
func (tc *TxnCollection) Peek() *transaction.Transaction
func (*TxnCollection) Pop ¶
func (tc *TxnCollection) Pop() *transaction.Transaction
func (*TxnCollection) Update ¶
func (tc *TxnCollection) Update() error
type TxnCollector ¶
TxnCollector collects transactions from transaction pool
func NewTxnCollector ¶
func NewTxnCollector(source TxnSource, num int) *TxnCollector
func (*TxnCollector) Cleanup ¶
func (tc *TxnCollector) Cleanup(txns []*transaction.Transaction) error
func (*TxnCollector) Collect ¶
func (tc *TxnCollector) Collect() (*TxnCollection, error)
func (*TxnCollector) GetTransaction ¶
func (tc *TxnCollector) GetTransaction(hash common.Uint256) *transaction.Transaction
type TxnSource ¶
type TxnSource interface { GetAllTransactionLists() map[common.Uint160][]*transaction.Transaction GetTxnByCount(num int) (map[common.Uint256]*transaction.Transaction, error) GetTransaction(hash common.Uint256) *transaction.Transaction AppendTxnPool(txn *transaction.Transaction) error CleanSubmittedTransactions(txns []*transaction.Transaction) error }
Transaction pool should be a concrete entity of this interface