Documentation ¶
Index ¶
- Constants
- Variables
- func AddChildrenWork(node *BlockNode, work *big.Int)
- func BigToCompact(n *big.Int) uint32
- func CalcPastMedianTime(node *BlockNode) time.Time
- func CalcWork(bits uint32) *big.Int
- func CalculateTxsFee(block *Block)
- func CheckDPOSIllegalBlocks(d *payload.DPOSIllegalBlocks) error
- func CheckDPOSIllegalProposals(d *payload.DPOSIllegalProposals) error
- func CheckDPOSIllegalVotes(d *payload.DPOSIllegalVotes) error
- func CheckInactiveArbitrators(txn *Transaction) error
- func CheckProofOfWork(header *Header, powLimit *big.Int) error
- func CheckSideChainPowConsensus(txn *Transaction, arbitrator []byte) error
- func CheckSidechainIllegalEvidence(p *payload.SidechainIllegalData) error
- func CompactToBig(compact uint32) *big.Int
- func ConfirmContextCheck(confirm *payload.Confirm) error
- func ConfirmSanityCheck(confirm *payload.Confirm) error
- func GetTxFee(tx *Transaction, assetId Uint256) Fixed64
- func GetTxFeeMap(tx *Transaction) (map[Uint256]Fixed64, error)
- func GetTxProgramHashes(tx *Transaction, references map[*Input]*Output) ([]common.Uint168, error)
- func GetUint16Array(source []byte) ([]uint16, error)
- func HashToBig(hash *Uint256) *big.Int
- func IsFinalizedTransaction(msgTx *Transaction, blockHeight uint32) bool
- func PreProcessSpecialTx(block *Block) error
- func ProposalCheck(proposal *payload.DPOSProposal) error
- func ProposalCheckByHeight(proposal *payload.DPOSProposal, height uint32) error
- func ProposalContextCheck(proposal *payload.DPOSProposal) error
- func ProposalContextCheckByHeight(proposal *payload.DPOSProposal, height uint32) error
- func ProposalSanityCheck(proposal *payload.DPOSProposal) error
- func RunPrograms(data []byte, programHashes []common.Uint168, programs []*Program) error
- func SortPrograms(programs []*Program)
- func ToByteArray(source []uint16) []byte
- func VoteCheck(vote *payload.DPOSProposalVote) error
- func VoteCheckByHeight(vote *payload.DPOSProposalVote, height uint32) error
- func VoteContextCheck(vote *payload.DPOSProposalVote) error
- func VoteContextCheckByHeight(vote *payload.DPOSProposalVote, height uint32) error
- func VoteSanityCheck(vote *payload.DPOSProposalVote) error
- type BlockChain
- func (b *BlockChain) AddNodeToIndex(node *BlockNode)
- func (b *BlockChain) AddOrphanBlock(block *Block)
- func (b *BlockChain) AddOrphanConfirm(confirm *payload.Confirm)
- func (b *BlockChain) BlockExists(hash *Uint256) bool
- func (b *BlockChain) BlockLocatorFromHash(inhash *Uint256) []*Uint256
- func (b *BlockChain) CalcCurrentDifficulty(currentBits uint32) string
- func (b *BlockChain) CalcNextRequiredDifficulty(prevNode *BlockNode, newBlockTime time.Time) (uint32, error)
- func (b *BlockChain) CheckBlockContext(block *Block, prevNode *BlockNode) error
- func (b *BlockChain) CheckBlockSanity(block *Block) error
- func (b *BlockChain) CheckTransactionContext(blockHeight uint32, txn *Transaction) ErrCode
- func (b *BlockChain) CheckTransactionSanity(blockHeight uint32, txn *Transaction) ErrCode
- func (b *BlockChain) ContainsTransaction(hash Uint256) bool
- func (b *BlockChain) CurrentBlockHash() Uint256
- func (b *BlockChain) GetBlockByHash(hash Uint256) (*Block, error)
- func (b *BlockChain) GetDposBlockByHash(hash Uint256) (*DposBlock, error)
- func (b *BlockChain) GetHeader(hash Uint256) (*Header, error)
- func (b *BlockChain) GetHeight() uint32
- func (b *BlockChain) GetNetworkHashPS() *big.Int
- func (b *BlockChain) GetOrphan(hash *Uint256) *OrphanBlock
- func (b *BlockChain) GetOrphanConfirm(hash *Uint256) (*payload.Confirm, bool)
- func (b *BlockChain) GetOrphanRoot(hash *Uint256) *Uint256
- func (b *BlockChain) GetState() *state.State
- func (b *BlockChain) HaveBlock(hash *Uint256) (bool, error)
- func (b *BlockChain) InitProducerState(interrupt <-chan struct{}, start func(total uint32), increase func()) (err error)
- func (b *BlockChain) IsKnownOrphan(hash *Uint256) bool
- func (b *BlockChain) LatestBlockLocator() ([]*Uint256, error)
- func (b *BlockChain) LoadBlockNode(blockHeader *Header, hash *Uint256) (*BlockNode, error)
- func (b *BlockChain) LocateBlocks(locator []*Uint256, hashStop *Uint256, maxHashes uint32) []*Uint256
- func (b *BlockChain) LookupNodeInIndex(hash *Uint256) (*BlockNode, bool)
- func (b *BlockChain) MedianAdjustedTime() time.Time
- func (b *BlockChain) ProcessBlock(block *Block, confirm *payload.Confirm) (bool, bool, error)
- func (b *BlockChain) ProcessIllegalBlock(payload *payload.DPOSIllegalBlocks)
- func (b *BlockChain) ProcessInactiveArbiter(payload *payload.InactiveArbitrators)
- func (b *BlockChain) ProcessOrphans(hash *Uint256) error
- func (b *BlockChain) RemoveNodeFromIndex(node *BlockNode)
- func (b *BlockChain) RemoveOrphanBlock(orphan *OrphanBlock)
- func (b *BlockChain) ReorganizeChain(block *Block) error
- type BlockNode
- type ChainStore
- func (c *ChainStore) Close()
- func (c *ChainStore) ContainsUnspent(txID Uint256, index uint16) (bool, error)
- func (c *ChainStore) GetAsset(hash Uint256) (*payload.Asset, error)
- func (c *ChainStore) GetAssets() map[Uint256]*payload.Asset
- func (c *ChainStore) GetBlock(hash Uint256) (*Block, error)
- func (c *ChainStore) GetBlockHash(height uint32) (Uint256, error)
- func (c *ChainStore) GetConfirm(hash Uint256) (*payload.Confirm, error)
- func (c *ChainStore) GetCurrentBlockHash() Uint256
- func (c *ChainStore) GetHeader(hash Uint256) (*Header, error)
- func (c *ChainStore) GetHeight() uint32
- func (c *ChainStore) GetSidechainTx(sidechainTxHash Uint256) (byte, error)
- func (c *ChainStore) GetTransaction(txID Uint256) (*Transaction, uint32, error)
- func (c *ChainStore) GetTxReference(tx *Transaction) (map[*Input]*Output, error)
- func (c *ChainStore) GetUnspent(txID Uint256, index uint16) (*Output, error)
- func (c *ChainStore) GetUnspentElementFromProgramHash(programHash Uint168, assetid Uint256, height uint32) ([]*UTXO, error)
- func (c *ChainStore) GetUnspentFromProgramHash(programHash Uint168, assetid Uint256) ([]*UTXO, error)
- func (c *ChainStore) GetUnspentsFromProgramHash(programHash Uint168) (map[Uint256][]*UTXO, error)
- func (c *ChainStore) IsBlockInStore(hash *Uint256) bool
- func (c *ChainStore) IsDoubleSpend(txn *Transaction) bool
- func (c *ChainStore) IsSidechainTxHashDuplicate(sidechainTxHash Uint256) bool
- func (c *ChainStore) IsTxHashDuplicate(txhash Uint256) bool
- func (c *ChainStore) PersistAsset(assetID Uint256, asset payload.Asset) error
- func (c *ChainStore) PersistConfirm(confirm *payload.Confirm) error
- func (c *ChainStore) PersistSidechainTx(sidechainTxHash Uint256)
- func (c *ChainStore) PersistTransactions(b *Block) error
- func (c *ChainStore) PersistUnspentWithProgramHash(programHash Uint168, assetid Uint256, height uint32, unspents []*UTXO) error
- func (c *ChainStore) RollbackBlock(blockHash Uint256) error
- func (c *ChainStore) RollbackBlockHash(b *Block) error
- func (c *ChainStore) RollbackConfirm(b *Block) error
- func (c *ChainStore) RollbackCurrentBlock(b *Block) error
- func (c *ChainStore) RollbackTransactions(b *Block) error
- func (c *ChainStore) RollbackTrimmedBlock(b *Block) error
- func (c *ChainStore) RollbackUnspend(b *Block) error
- func (c *ChainStore) RollbackUnspendUTXOs(b *Block) error
- func (c *ChainStore) SaveBlock(b *Block, confirm *payload.Confirm) error
- type DataEntryPrefix
- type IChainStore
- type IIterator
- type IStore
- type Iterator
- type Ledger
- func (l *Ledger) AppendDposBlocks(confirms []*DposBlock) error
- func (l *Ledger) GetAsset(assetID Uint256) (*payload.Asset, error)
- func (l *Ledger) GetBlockWithHash(hash Uint256) (*Block, error)
- func (l *Ledger) GetBlockWithHeight(height uint32) (*Block, error)
- func (l *Ledger) GetDposBlocks(start, end uint32) ([]*DposBlock, error)
- func (l *Ledger) GetLocalBlockChainHeight() uint32
- func (l *Ledger) GetTransactionWithHash(hash Uint256) (*Transaction, error)
- func (l *Ledger) IsDoubleSpend(Tx *Transaction) bool
- type LevelDB
- func (ldb *LevelDB) BatchCommit() error
- func (ldb *LevelDB) BatchDelete(key []byte)
- func (ldb *LevelDB) BatchPut(key []byte, value []byte)
- func (ldb *LevelDB) Close() error
- func (ldb *LevelDB) Delete(key []byte) error
- func (ldb *LevelDB) Get(key []byte) ([]byte, error)
- func (ldb *LevelDB) NewBatch()
- func (ldb *LevelDB) NewIterator(prefix []byte) IIterator
- func (ldb *LevelDB) Put(key []byte, value []byte) error
- type MedianTimeSource
- type OrphanBlock
- type ProducerInfo
- type ProducerState
- type UTXO
Constants ¶
const ( TaskChanCap = 4 BlocksCacheSize = 2 )
const ( // MinDepositAmount is the minimum deposit as a producer. MinDepositAmount = 5000 * 100000000 // DepositLockupBlocks indicates how many blocks need to wait when cancel // producer was triggered, and can submit return deposit coin request. DepositLockupBlocks = 2160 // MaxStringLength is the maximum length of a string field. MaxStringLength = 100 )
const BITSPERKEY = 10
used to compute the size of bloom filter bits array . too small will lead to high false positive rate.
const (
MaxTimeOffsetSeconds = 2 * 60 * 60
)
Variables ¶
var FoundationAddress Uint168
Functions ¶
func AddChildrenWork ¶
func BigToCompact ¶
func CalcPastMedianTime ¶
func CalculateTxsFee ¶ added in v0.3.3
func CalculateTxsFee(block *Block)
func CheckDPOSIllegalBlocks ¶ added in v0.3.0
func CheckDPOSIllegalBlocks(d *payload.DPOSIllegalBlocks) error
func CheckDPOSIllegalProposals ¶ added in v0.3.0
func CheckDPOSIllegalProposals(d *payload.DPOSIllegalProposals) error
func CheckDPOSIllegalVotes ¶ added in v0.3.0
func CheckDPOSIllegalVotes(d *payload.DPOSIllegalVotes) error
func CheckInactiveArbitrators ¶ added in v0.3.0
func CheckInactiveArbitrators(txn *Transaction) error
func CheckProofOfWork ¶
func CheckSideChainPowConsensus ¶ added in v0.1.1
func CheckSidechainIllegalEvidence ¶ added in v0.3.0
func CheckSidechainIllegalEvidence(p *payload.SidechainIllegalData) error
func CompactToBig ¶
func ConfirmContextCheck ¶ added in v0.3.0
func ConfirmSanityCheck ¶ added in v0.3.0
func GetTxFeeMap ¶
func GetTxFeeMap(tx *Transaction) (map[Uint256]Fixed64, error)
func GetTxProgramHashes ¶
func GetUint16Array ¶
func IsFinalizedTransaction ¶
func PreProcessSpecialTx ¶ added in v0.3.2
func PreProcessSpecialTx(block *Block) error
func ProposalCheck ¶ added in v0.3.2
func ProposalCheck(proposal *payload.DPOSProposal) error
func ProposalCheckByHeight ¶ added in v0.3.2
func ProposalCheckByHeight(proposal *payload.DPOSProposal, height uint32) error
func ProposalContextCheck ¶ added in v0.3.0
func ProposalContextCheck(proposal *payload.DPOSProposal) error
func ProposalContextCheckByHeight ¶ added in v0.3.2
func ProposalContextCheckByHeight(proposal *payload.DPOSProposal, height uint32) error
func ProposalSanityCheck ¶ added in v0.3.0
func ProposalSanityCheck(proposal *payload.DPOSProposal) error
func RunPrograms ¶
func SortPrograms ¶ added in v0.1.1
func SortPrograms(programs []*Program)
func ToByteArray ¶
func VoteCheck ¶ added in v0.3.2
func VoteCheck(vote *payload.DPOSProposalVote) error
func VoteCheckByHeight ¶ added in v0.3.2
func VoteCheckByHeight(vote *payload.DPOSProposalVote, height uint32) error
func VoteContextCheck ¶ added in v0.3.0
func VoteContextCheck(vote *payload.DPOSProposalVote) error
func VoteContextCheckByHeight ¶ added in v0.3.2
func VoteContextCheckByHeight(vote *payload.DPOSProposalVote, height uint32) error
func VoteSanityCheck ¶ added in v0.3.0
func VoteSanityCheck(vote *payload.DPOSProposalVote) error
Types ¶
type BlockChain ¶ added in v0.3.0
type BlockChain struct { GenesisHash Uint256 BestChain *BlockNode Root *BlockNode Index map[Uint256]*BlockNode IndexLock sync.RWMutex DepNodes map[Uint256][]*BlockNode TimeSource MedianTimeSource MedianTimePast time.Time // contains filtered or unexported fields }
func New ¶ added in v0.3.0
func New(db IChainStore, chainParams *config.Params, state *state.State) (*BlockChain, error)
func (*BlockChain) AddNodeToIndex ¶ added in v0.3.0
func (b *BlockChain) AddNodeToIndex(node *BlockNode)
func (*BlockChain) AddOrphanBlock ¶ added in v0.3.0
func (b *BlockChain) AddOrphanBlock(block *Block)
func (*BlockChain) AddOrphanConfirm ¶ added in v0.3.0
func (b *BlockChain) AddOrphanConfirm(confirm *payload.Confirm)
func (*BlockChain) BlockExists ¶ added in v0.3.0
func (b *BlockChain) BlockExists(hash *Uint256) bool
func (*BlockChain) BlockLocatorFromHash ¶ added in v0.3.0
func (b *BlockChain) BlockLocatorFromHash(inhash *Uint256) []*Uint256
func (*BlockChain) CalcCurrentDifficulty ¶ added in v0.3.0
func (b *BlockChain) CalcCurrentDifficulty(currentBits uint32) string
func (*BlockChain) CalcNextRequiredDifficulty ¶ added in v0.3.0
func (*BlockChain) CheckBlockContext ¶ added in v0.3.4
func (b *BlockChain) CheckBlockContext(block *Block, prevNode *BlockNode) error
func (*BlockChain) CheckBlockSanity ¶ added in v0.3.0
func (b *BlockChain) CheckBlockSanity(block *Block) error
func (*BlockChain) CheckTransactionContext ¶ added in v0.3.0
func (b *BlockChain) CheckTransactionContext(blockHeight uint32, txn *Transaction) ErrCode
CheckTransactionContext verifies a transaction with history transaction in ledger
func (*BlockChain) CheckTransactionSanity ¶ added in v0.3.0
func (b *BlockChain) CheckTransactionSanity(blockHeight uint32, txn *Transaction) ErrCode
CheckTransactionSanity verifies received single transaction
func (*BlockChain) ContainsTransaction ¶ added in v0.3.0
func (b *BlockChain) ContainsTransaction(hash Uint256) bool
func (*BlockChain) CurrentBlockHash ¶ added in v0.3.0
func (b *BlockChain) CurrentBlockHash() Uint256
func (*BlockChain) GetBlockByHash ¶ added in v0.3.0
func (b *BlockChain) GetBlockByHash(hash Uint256) (*Block, error)
Get block with block hash.
func (*BlockChain) GetDposBlockByHash ¶ added in v0.3.0
func (b *BlockChain) GetDposBlockByHash(hash Uint256) (*DposBlock, error)
Get DPOS block with block hash.
func (*BlockChain) GetHeader ¶ added in v0.3.0
func (b *BlockChain) GetHeader(hash Uint256) (*Header, error)
func (*BlockChain) GetHeight ¶ added in v0.3.0
func (b *BlockChain) GetHeight() uint32
func (*BlockChain) GetNetworkHashPS ¶ added in v0.3.4
func (b *BlockChain) GetNetworkHashPS() *big.Int
GetNetworkHashPS return average network hashes per second based on the last 'lookup' blocks.
func (*BlockChain) GetOrphan ¶ added in v0.3.2
func (b *BlockChain) GetOrphan(hash *Uint256) *OrphanBlock
func (*BlockChain) GetOrphanConfirm ¶ added in v0.3.0
func (b *BlockChain) GetOrphanConfirm(hash *Uint256) (*payload.Confirm, bool)
func (*BlockChain) GetOrphanRoot ¶ added in v0.3.0
func (b *BlockChain) GetOrphanRoot(hash *Uint256) *Uint256
func (*BlockChain) GetState ¶ added in v0.3.0
func (b *BlockChain) GetState() *state.State
GetState returns the DPOS state instance that stores producers and votes information.
func (*BlockChain) HaveBlock ¶ added in v0.3.0
func (b *BlockChain) HaveBlock(hash *Uint256) (bool, error)
func (*BlockChain) InitProducerState ¶ added in v0.3.2
func (b *BlockChain) InitProducerState(interrupt <-chan struct{}, start func(total uint32), increase func()) (err error)
InitProducerState go through all blocks since the start of DPOS consensus to initialize producers and votes state.
func (*BlockChain) IsKnownOrphan ¶ added in v0.3.0
func (b *BlockChain) IsKnownOrphan(hash *Uint256) bool
func (*BlockChain) LatestBlockLocator ¶ added in v0.3.0
func (b *BlockChain) LatestBlockLocator() ([]*Uint256, error)
func (*BlockChain) LoadBlockNode ¶ added in v0.3.0
func (b *BlockChain) LoadBlockNode(blockHeader *Header, hash *Uint256) (*BlockNode, error)
func (*BlockChain) LocateBlocks ¶ added in v0.3.0
func (b *BlockChain) LocateBlocks(locator []*Uint256, hashStop *Uint256, maxHashes uint32) []*Uint256
LocateBlocks returns the hashes of the blocks after the first known block in the locator until the provided stop hash is reached, or up to the provided max number of block hashes.
In addition, there are two special cases:
- When no locators are provided, the stop hash is treated as a request for that block, so it will either return the stop hash itself if it is known, or nil if it is unknown
- When locators are provided, but none of them are known, hashes starting after the genesis block will be returned
This function is safe for concurrent access.
func (*BlockChain) LookupNodeInIndex ¶ added in v0.3.0
func (b *BlockChain) LookupNodeInIndex(hash *Uint256) (*BlockNode, bool)
func (*BlockChain) MedianAdjustedTime ¶ added in v0.3.0
func (b *BlockChain) MedianAdjustedTime() time.Time
func (*BlockChain) ProcessBlock ¶ added in v0.3.0
func (*BlockChain) ProcessIllegalBlock ¶ added in v0.3.0
func (b *BlockChain) ProcessIllegalBlock(payload *payload.DPOSIllegalBlocks)
func (*BlockChain) ProcessInactiveArbiter ¶ added in v0.3.2
func (b *BlockChain) ProcessInactiveArbiter(payload *payload.InactiveArbitrators)
func (*BlockChain) ProcessOrphans ¶ added in v0.3.0
func (b *BlockChain) ProcessOrphans(hash *Uint256) error
func (*BlockChain) RemoveNodeFromIndex ¶ added in v0.3.0
func (b *BlockChain) RemoveNodeFromIndex(node *BlockNode)
func (*BlockChain) RemoveOrphanBlock ¶ added in v0.3.0
func (b *BlockChain) RemoveOrphanBlock(orphan *OrphanBlock)
func (*BlockChain) ReorganizeChain ¶ added in v0.3.0
func (b *BlockChain) ReorganizeChain(block *Block) error
ReorganizeChain reorganize chain by specify a block, this method shall not be called normally because it can cause reorganizing without node work sum checking
type BlockNode ¶
type BlockNode struct { Hash *Uint256 ParentHash *Uint256 Height uint32 Version uint32 Bits uint32 Timestamp uint32 WorkSum *big.Int InMainChain bool Parent *BlockNode Children []*BlockNode }
func NewBlockNode ¶
func NewBlockNode(header *Header, hash *Uint256) *BlockNode
func RemoveChildNode ¶
type ChainStore ¶
type ChainStore struct { IStore // contains filtered or unexported fields }
func (*ChainStore) Close ¶
func (c *ChainStore) Close()
func (*ChainStore) ContainsUnspent ¶
func (c *ChainStore) ContainsUnspent(txID Uint256, index uint16) (bool, error)
func (*ChainStore) GetAssets ¶
func (c *ChainStore) GetAssets() map[Uint256]*payload.Asset
func (*ChainStore) GetBlock ¶
func (c *ChainStore) GetBlock(hash Uint256) (*Block, error)
func (*ChainStore) GetBlockHash ¶
func (c *ChainStore) GetBlockHash(height uint32) (Uint256, error)
func (*ChainStore) GetConfirm ¶ added in v0.2.2
func (c *ChainStore) GetConfirm(hash Uint256) (*payload.Confirm, error)
func (*ChainStore) GetCurrentBlockHash ¶
func (c *ChainStore) GetCurrentBlockHash() Uint256
func (*ChainStore) GetHeader ¶
func (c *ChainStore) GetHeader(hash Uint256) (*Header, error)
func (*ChainStore) GetHeight ¶
func (c *ChainStore) GetHeight() uint32
func (*ChainStore) GetSidechainTx ¶ added in v0.1.1
func (c *ChainStore) GetSidechainTx(sidechainTxHash Uint256) (byte, error)
func (*ChainStore) GetTransaction ¶
func (c *ChainStore) GetTransaction(txID Uint256) (*Transaction, uint32, error)
func (*ChainStore) GetTxReference ¶
func (c *ChainStore) GetTxReference(tx *Transaction) (map[*Input]*Output, error)
func (*ChainStore) GetUnspent ¶
func (c *ChainStore) GetUnspent(txID Uint256, index uint16) (*Output, error)
func (*ChainStore) GetUnspentElementFromProgramHash ¶
func (c *ChainStore) GetUnspentElementFromProgramHash(programHash Uint168, assetid Uint256, height uint32) ([]*UTXO, error)
func (*ChainStore) GetUnspentFromProgramHash ¶
func (c *ChainStore) GetUnspentFromProgramHash(programHash Uint168, assetid Uint256) ([]*UTXO, error)
func (*ChainStore) GetUnspentsFromProgramHash ¶
func (c *ChainStore) GetUnspentsFromProgramHash(programHash Uint168) (map[Uint256][]*UTXO, error)
func (*ChainStore) IsBlockInStore ¶
func (c *ChainStore) IsBlockInStore(hash *Uint256) bool
func (*ChainStore) IsDoubleSpend ¶
func (c *ChainStore) IsDoubleSpend(txn *Transaction) bool
func (*ChainStore) IsSidechainTxHashDuplicate ¶ added in v0.1.1
func (c *ChainStore) IsSidechainTxHashDuplicate(sidechainTxHash Uint256) bool
func (*ChainStore) IsTxHashDuplicate ¶
func (c *ChainStore) IsTxHashDuplicate(txhash Uint256) bool
func (*ChainStore) PersistAsset ¶
func (c *ChainStore) PersistAsset(assetID Uint256, asset payload.Asset) error
func (*ChainStore) PersistConfirm ¶ added in v0.2.2
func (c *ChainStore) PersistConfirm( confirm *payload.Confirm) error
func (*ChainStore) PersistSidechainTx ¶ added in v0.1.1
func (c *ChainStore) PersistSidechainTx(sidechainTxHash Uint256)
func (*ChainStore) PersistTransactions ¶
func (c *ChainStore) PersistTransactions(b *Block) error
func (*ChainStore) PersistUnspentWithProgramHash ¶
func (c *ChainStore) PersistUnspentWithProgramHash(programHash Uint168, assetid Uint256, height uint32, unspents []*UTXO) error
func (*ChainStore) RollbackBlock ¶
func (c *ChainStore) RollbackBlock(blockHash Uint256) error
func (*ChainStore) RollbackBlockHash ¶
func (c *ChainStore) RollbackBlockHash(b *Block) error
func (*ChainStore) RollbackConfirm ¶ added in v0.2.2
func (c *ChainStore) RollbackConfirm(b *Block) error
func (*ChainStore) RollbackCurrentBlock ¶
func (c *ChainStore) RollbackCurrentBlock(b *Block) error
func (*ChainStore) RollbackTransactions ¶
func (c *ChainStore) RollbackTransactions(b *Block) error
func (*ChainStore) RollbackTrimmedBlock ¶
func (c *ChainStore) RollbackTrimmedBlock(b *Block) error
func (*ChainStore) RollbackUnspend ¶
func (c *ChainStore) RollbackUnspend(b *Block) error
func (*ChainStore) RollbackUnspendUTXOs ¶
func (c *ChainStore) RollbackUnspendUTXOs(b *Block) error
type DataEntryPrefix ¶
type DataEntryPrefix byte
DataEntryPrefix
const ( // DATA DATABlockHash DataEntryPrefix = 0x00 DATAHeader DataEntryPrefix = 0x01 DATATransaction DataEntryPrefix = 0x02 DATAConfirm DataEntryPrefix = 0x03 //SYSTEM SYSCurrentBlock DataEntryPrefix = 0x40 SYSCurrentBookKeeper DataEntryPrefix = 0x42 // INDEX IXHeaderHashList DataEntryPrefix = 0x80 IXUnspent DataEntryPrefix = 0x90 IXUnspentUTXO DataEntryPrefix = 0x91 IXSideChainTx DataEntryPrefix = 0x92 // ASSET STInfo DataEntryPrefix = 0xc0 // DPOS DPOSIllegalProducer DataEntryPrefix = 0xd1 //CONFIG CFGVersion DataEntryPrefix = 0xf0 )
type IChainStore ¶
type IChainStore interface { SaveBlock(b *Block, confirm *payload.Confirm) error GetBlock(hash Uint256) (*Block, error) GetBlockHash(height uint32) (Uint256, error) IsDoubleSpend(tx *Transaction) bool GetConfirm(hash Uint256) (*payload.Confirm, error) GetHeader(hash Uint256) (*Header, error) RollbackBlock(hash Uint256) error GetTransaction(txID Uint256) (*Transaction, uint32, error) GetTxReference(tx *Transaction) (map[*Input]*Output, error) PersistAsset(assetid Uint256, asset payload.Asset) error GetAsset(hash Uint256) (*payload.Asset, error) PersistSidechainTx(sidechainTxHash Uint256) GetSidechainTx(sidechainTxHash Uint256) (byte, error) GetCurrentBlockHash() Uint256 GetHeight() uint32 GetUnspent(txID Uint256, index uint16) (*Output, error) ContainsUnspent(txID Uint256, index uint16) (bool, error) GetUnspentFromProgramHash(programHash Uint168, assetid Uint256) ([]*UTXO, error) GetUnspentsFromProgramHash(programHash Uint168) (map[Uint256][]*UTXO, error) GetAssets() map[Uint256]*payload.Asset IsTxHashDuplicate(txhash Uint256) bool IsSidechainTxHashDuplicate(sidechainTxHash Uint256) bool IsBlockInStore(hash *Uint256) bool Close() }
IChainStore provides func with store package.
func NewChainStore ¶
func NewChainStore(dataDir string, genesisBlock *Block) (IChainStore, error)
type Ledger ¶
type Ledger struct { Blockchain *BlockChain Store IChainStore Arbitrators state.Arbitrators }
Ledger - the struct for ledger
var DefaultLedger *Ledger
func (*Ledger) AppendDposBlocks ¶ added in v0.2.2
Append blocks and confirms directly
func (*Ledger) GetBlockWithHash ¶
Get block with block hash.
func (*Ledger) GetBlockWithHeight ¶
Get Block With Height.
func (*Ledger) GetDposBlocks ¶ added in v0.2.2
Get blocks and confirms by given height range, if end equals zero will be treat as current highest block height
func (*Ledger) GetLocalBlockChainHeight ¶
Get local block chain height.
func (*Ledger) GetTransactionWithHash ¶
Get transaction with hash.
func (*Ledger) IsDoubleSpend ¶
check weather the transaction contains the doubleSpend.
type LevelDB ¶
type LevelDB struct {
// contains filtered or unexported fields
}
func NewLevelDB ¶
func (*LevelDB) BatchCommit ¶
func (*LevelDB) BatchDelete ¶
func (*LevelDB) NewIterator ¶
type MedianTimeSource ¶
type MedianTimeSource interface { // AdjustedTime returns the current time adjusted by the median time // offset as calculated from the time samples added by AddTimeSample. AdjustedTime() time.Time // AddTimeSample adds a time sample that is used when determining the // median time of the added samples. AddTimeSample(id string, timeVal time.Time) // Offset returns the number of seconds to adjust the local clock based // upon the median of the time samples added by AddTimeData. Offset() time.Duration }
MedianTimeSource provides a mechanism to add several time samples which are used to determine a median time which is then used as an offset to the local clock.
func NewMedianTime ¶
func NewMedianTime() MedianTimeSource
NewMedianTime returns a new instance of concurrency-safe implementation of the MedianTimeSource interface. The returned implementation contains the rules necessary for proper time handling in the chain consensus rules and expects the time samples to be added from the timestamp field of the version message received from remote peers that successfully connect and negotiate.
type OrphanBlock ¶
type ProducerInfo ¶ added in v0.2.2
type ProducerInfo struct { Payload *payload.ProducerInfo RegHeight uint32 Vote Fixed64 }
type ProducerState ¶ added in v0.2.2
type ProducerState byte