Documentation ¶
Index ¶
- Constants
- Variables
- func AddChildrenWork(node *BlockNode, work *big.Int)
- func BigToCompact(n *big.Int) uint32
- func CalcCurrentDifficulty(currentBits uint32) string
- func CalcNextRequiredDifficulty(prevNode *BlockNode, newBlockTime time.Time) (uint32, error)
- func CalcPastMedianTime(node *BlockNode) time.Time
- func CalcWork(bits uint32) *big.Int
- func CheckAssetPrecision(txn *Transaction) error
- func CheckAttributeProgram(tx *Transaction) error
- func CheckBlockContext(block *Block) error
- func CheckDestructionAddress(references map[*Input]*Output) error
- func CheckDuplicateSidechainTx(txn *Transaction) error
- func CheckOutputProgramHash(programHash Uint168) bool
- func CheckProofOfWork(header *Header, powLimit *big.Int) error
- func CheckSideChainPowConsensus(txn *Transaction, arbitrator []byte) error
- func CheckTransactionCoinbaseOutputLock(txn *Transaction) error
- func CheckTransactionContext(txn *Transaction) ErrCode
- func CheckTransactionFee(tx *Transaction, references map[*Input]*Output) error
- func CheckTransactionInput(txn *Transaction) error
- func CheckTransactionOutput(version uint32, txn *Transaction) error
- func CheckTransactionPayload(txn *Transaction) error
- func CheckTransactionSanity(version uint32, txn *Transaction) ErrCode
- func CheckTransactionSignature(tx *Transaction, references map[*Input]*Output) error
- func CheckTransactionSize(txn *Transaction) error
- func CheckTransactionUTXOLock(txn *Transaction, references map[*Input]*Output) error
- func CheckTransferCrossChainAssetTransaction(txn *Transaction, references map[*Input]*Output) error
- func CheckWithdrawFromSideChainTransaction(txn *Transaction, references map[*Input]*Output) error
- func CompactToBig(compact uint32) *big.Int
- func DumpBlockNode(node *BlockNode)
- func GetCurrentArbiter() ([]byte, error)
- func GetGenesisBlock() (*Block, 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 Init(store IChainStore) error
- func IsFinalizedTransaction(msgTx *Transaction, blockHeight uint32) bool
- func NewCoinBaseTransaction(coinBasePayload *PayloadCoinBase, currentHeight uint32) *Transaction
- func PowCheckBlockContext(block *Block, prevNode *BlockNode, ledger *Ledger) error
- func PowCheckBlockSanity(block *Block, powLimit *big.Int, timeSource MedianTimeSource) error
- func RunPrograms(data []byte, hashes []common.Uint168, programs []*Program) error
- func SortPrograms(programs []*Program) (err error)
- func ToByteArray(source []uint16) []byte
- type BlockNode
- type Blockchain
- func (b *Blockchain) AddBlock(block *Block) (bool, bool, error)
- func (b *Blockchain) AddNodeToIndex(node *BlockNode)
- func (b *Blockchain) AddOrphanBlock(block *Block)
- func (b *Blockchain) BlockExists(hash *Uint256) bool
- func (b *Blockchain) BlockLocatorFromHash(inhash *Uint256) []*Uint256
- func (b *Blockchain) ConnectBestChain(node *BlockNode, block *Block) (bool, error)
- func (b *Blockchain) ConnectBlock(node *BlockNode, block *Block) error
- func (b *Blockchain) ContainsTransaction(hash Uint256) bool
- func (b *Blockchain) CurrentBlockHash() Uint256
- func (b *Blockchain) DisconnectBlock(node *BlockNode, block *Block) error
- func (b *Blockchain) DumpState()
- func (b *Blockchain) GetBestHeight() uint32
- func (b *Blockchain) GetHeader(hash Uint256) (*Header, error)
- func (b *Blockchain) GetOrphanRoot(hash *Uint256) *Uint256
- func (b *Blockchain) GetPrevNodeFromBlock(block *Block) (*BlockNode, error)
- func (b *Blockchain) GetPrevNodeFromNode(node *BlockNode) (*BlockNode, error)
- func (b *Blockchain) GetReorganizeNodes(node *BlockNode) (*list.List, *list.List)
- func (b *Blockchain) IsKnownOrphan(hash *Uint256) bool
- func (b *Blockchain) LatestBlockLocator() ([]*Uint256, error)
- func (b *Blockchain) LatestLocatorHash(locator []*Uint256) *Uint256
- func (b *Blockchain) LoadBlockNode(blockHeader *Header, hash *Uint256) (*BlockNode, error)
- func (b *Blockchain) LookupNodeInIndex(hash *Uint256) (*BlockNode, bool)
- func (b *Blockchain) MedianAdjustedTime() time.Time
- func (b *Blockchain) ProcessBlock(block *Block) (bool, bool, error)
- func (b *Blockchain) ProcessOrphans(hash *Uint256) error
- func (b *Blockchain) PruneBlockNodes() error
- func (b *Blockchain) RemoveBlockNode(node *BlockNode) error
- func (b *Blockchain) RemoveNodeFromIndex(node *BlockNode)
- func (b *Blockchain) RemoveOrphanBlock(orphan *OrphanBlock)
- func (b *Blockchain) ReorganizeChain(detachNodes, attachNodes *list.List) error
- func (b *Blockchain) UpdateBestHeight(val uint32)
- type ChainStore
- func (c *ChainStore) Close()
- func (c *ChainStore) ContainsUnspent(txID Uint256, index uint16) (bool, error)
- func (c *ChainStore) GetAsset(hash Uint256) (*Asset, error)
- func (c *ChainStore) GetAssets() map[Uint256]*Asset
- func (c *ChainStore) GetBlock(hash Uint256) (*Block, error)
- func (c *ChainStore) GetBlockHash(height uint32) (Uint256, 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) InitWithGenesisBlock(genesisBlock *Block) (uint32, 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 Asset) error
- func (c *ChainStore) PersistBlockHash(b *Block) error
- func (c *ChainStore) PersistCurrentBlock(b *Block) error
- func (c *ChainStore) PersistSidechainTx(sidechainTxHash Uint256)
- func (c *ChainStore) PersistTransaction(tx *Transaction, height uint32) error
- func (c *ChainStore) PersistTransactions(b *Block) error
- func (c *ChainStore) PersistTrimmedBlock(b *Block) error
- func (c *ChainStore) PersistUnspend(b *Block) error
- func (c *ChainStore) PersistUnspendUTXOs(b *Block) error
- func (c *ChainStore) PersistUnspentWithProgramHash(programHash Uint168, assetid Uint256, height uint32, unspents []*UTXO) error
- func (c *ChainStore) RemoveHeaderListElement(hash Uint256)
- func (c *ChainStore) RollbackAsset(assetID Uint256) error
- func (c *ChainStore) RollbackBlock(blockHash Uint256) error
- func (c *ChainStore) RollbackBlockHash(b *Block) error
- func (c *ChainStore) RollbackCurrentBlock(b *Block) error
- func (c *ChainStore) RollbackSidechainTx(sidechainTxHash Uint256) error
- func (c *ChainStore) RollbackTransaction(txn *Transaction) 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) error
- type DataEntryPrefix
- type IChainStore
- type IIterator
- type IStore
- type Iterator
- type Ledger
- func (l *Ledger) BlockInLedger(hash Uint256) bool
- func (l *Ledger) GetAsset(assetID Uint256) (*Asset, error)
- func (l *Ledger) GetBlockWithHash(hash Uint256) (*Block, error)
- func (l *Ledger) GetBlockWithHeight(height uint32) (*Block, 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 TxPool
- func (pool *TxPool) AppendToTxnPool(txn *Transaction) ErrCode
- func (pool *TxPool) CleanSubmittedTransactions(block *Block) error
- func (pool *TxPool) GetTransaction(hash Uint256) *Transaction
- func (pool *TxPool) GetTransactionCount() int
- func (pool *TxPool) GetTransactionPool(hasMaxCount bool) map[Uint256]*Transaction
- func (pool *TxPool) Init()
- func (pool *TxPool) IsDuplicateSidechainTx(sidechainTxHash Uint256) bool
- func (pool *TxPool) MaybeAcceptTransaction(txn *Transaction) error
- func (pool *TxPool) RemoveTransaction(txn *Transaction)
- type UTXO
Constants ¶
const BITSPERKEY = 10
used to compute the size of bloom filter bits array . too small will lead to high false positive rate.
const (
MaxBlockLocatorsPerMsg = 500
)
const (
MaxTimeOffsetSeconds = 2 * 60 * 60
)
const TaskChanCap = 4
const ValueExist = 1
const ValueNone = 0
Variables ¶
var ( OriginIssuanceAmount = 20000 * 10000 * 100000000 InflationPerYear = OriginIssuanceAmount * 3 / 100 BlockGenerateInterval = int64(config.Parameters.ChainParam.TargetTimePerBlock / time.Second) GeneratedBlocksPerYear = 365 * 24 * 60 * 60 / BlockGenerateInterval TotalRewardAmountPerBlock = common.Fixed64(float64(24 * 100000000)) MinerRewardAmountPerBlock = common.Fixed64(float64(4 * 100000000)) FoundationRewardAmountPerBlock = common.Fixed64(float64(20 * 100000000)) )
var FoundationAddress Uint168
var FoundationAddress1 Uint168
var FoundationAddress10 Uint168
var FoundationAddress11 Uint168
var FoundationAddress2 Uint168
var FoundationAddress3 Uint168
var FoundationAddress4 Uint168
var FoundationAddress5 Uint168
var FoundationAddress6 Uint168
var FoundationAddress7 Uint168
var FoundationAddress8 Uint168
var FoundationAddress9 Uint168
var (
MinMemoryNodes = config.Parameters.ChainParam.MinMemoryNodes
)
Functions ¶
func AddChildrenWork ¶
func BigToCompact ¶
func CalcCurrentDifficulty ¶
func CalcPastMedianTime ¶
func CheckAssetPrecision ¶
func CheckAssetPrecision(txn *Transaction) error
func CheckAttributeProgram ¶
func CheckAttributeProgram(tx *Transaction) error
func CheckBlockContext ¶ added in v0.2.0
func CheckBlockContext(block *Block) error
func CheckDestructionAddress ¶ added in v0.2.0
func CheckDestructionAddress(references map[*Input]*Output) error
func CheckDuplicateSidechainTx ¶ added in v0.2.0
func CheckDuplicateSidechainTx(txn *Transaction) error
validate the transaction of duplicate sidechain transaction
func CheckOutputProgramHash ¶ added in v0.2.0
func CheckOutputProgramHash(programHash Uint168) bool
func CheckProofOfWork ¶
func CheckSideChainPowConsensus ¶ added in v0.2.0
func CheckTransactionCoinbaseOutputLock ¶ added in v0.2.0
func CheckTransactionCoinbaseOutputLock(txn *Transaction) error
func CheckTransactionContext ¶
func CheckTransactionContext(txn *Transaction) ErrCode
CheckTransactionContext verifys a transaction with history transaction in ledger
func CheckTransactionFee ¶ added in v0.2.0
func CheckTransactionFee(tx *Transaction, references map[*Input]*Output) error
func CheckTransactionInput ¶
func CheckTransactionInput(txn *Transaction) error
validate the transaction of duplicate UTXO input
func CheckTransactionOutput ¶
func CheckTransactionPayload ¶
func CheckTransactionPayload(txn *Transaction) error
func CheckTransactionSanity ¶
func CheckTransactionSanity(version uint32, txn *Transaction) ErrCode
CheckTransactionSanity verifys received single transaction
func CheckTransactionSignature ¶
func CheckTransactionSignature(tx *Transaction, references map[*Input]*Output) error
func CheckTransactionSize ¶
func CheckTransactionSize(txn *Transaction) error
func CheckTransactionUTXOLock ¶
func CheckTransactionUTXOLock(txn *Transaction, references map[*Input]*Output) error
func CheckTransferCrossChainAssetTransaction ¶ added in v0.2.0
func CheckTransferCrossChainAssetTransaction(txn *Transaction, references map[*Input]*Output) error
func CheckWithdrawFromSideChainTransaction ¶ added in v0.2.0
func CheckWithdrawFromSideChainTransaction(txn *Transaction, references map[*Input]*Output) error
func CompactToBig ¶
func DumpBlockNode ¶
func DumpBlockNode(node *BlockNode)
func GetCurrentArbiter ¶ added in v0.2.0
func GetGenesisBlock ¶
func GetGenesisBlock() (*Block, error)
func GetTxFeeMap ¶
func GetTxFeeMap(tx *Transaction) (map[Uint256]Fixed64, error)
func GetTxProgramHashes ¶
func GetUint16Array ¶
func Init ¶
func Init(store IChainStore) error
func IsFinalizedTransaction ¶
func NewCoinBaseTransaction ¶
func NewCoinBaseTransaction(coinBasePayload *PayloadCoinBase, currentHeight uint32) *Transaction
func PowCheckBlockContext ¶
func PowCheckBlockSanity ¶
func PowCheckBlockSanity(block *Block, powLimit *big.Int, timeSource MedianTimeSource) error
func RunPrograms ¶
func SortPrograms ¶ added in v0.2.0
func SortPrograms(programs []*Program) (err error)
func ToByteArray ¶
Types ¶
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 Blockchain ¶
type Blockchain struct { BlockHeight uint32 GenesisHash Uint256 BestChain *BlockNode Root *BlockNode Index map[Uint256]*BlockNode IndexLock sync.RWMutex DepNodes map[Uint256][]*BlockNode Orphans map[Uint256]*OrphanBlock PrevOrphans map[Uint256][]*OrphanBlock OldestOrphan *OrphanBlock BlockCache map[Uint256]*Block TimeSource MedianTimeSource MedianTimePast time.Time OrphanLock sync.RWMutex BCEvents *events.Event AssetID Uint256 // contains filtered or unexported fields }
func NewBlockchain ¶
func NewBlockchain(height uint32) *Blockchain
func (*Blockchain) AddNodeToIndex ¶
func (b *Blockchain) AddNodeToIndex(node *BlockNode)
func (*Blockchain) AddOrphanBlock ¶
func (b *Blockchain) AddOrphanBlock(block *Block)
func (*Blockchain) BlockExists ¶
func (b *Blockchain) BlockExists(hash *Uint256) bool
func (*Blockchain) BlockLocatorFromHash ¶
func (b *Blockchain) BlockLocatorFromHash(inhash *Uint256) []*Uint256
func (*Blockchain) ConnectBestChain ¶
func (b *Blockchain) ConnectBestChain(node *BlockNode, block *Block) (bool, error)
func (*Blockchain) ConnectBlock ¶
func (b *Blockchain) ConnectBlock(node *BlockNode, block *Block) error
connectBlock handles connecting the passed node/block to the end of the main (best) chain.
func (*Blockchain) ContainsTransaction ¶
func (b *Blockchain) ContainsTransaction(hash Uint256) bool
func (*Blockchain) CurrentBlockHash ¶
func (b *Blockchain) CurrentBlockHash() Uint256
func (*Blockchain) DisconnectBlock ¶
func (b *Blockchain) DisconnectBlock(node *BlockNode, block *Block) error
// disconnectBlock handles disconnecting the passed node/block from the end of // the main (best) chain.
func (*Blockchain) DumpState ¶
func (b *Blockchain) DumpState()
func (*Blockchain) GetBestHeight ¶
func (b *Blockchain) GetBestHeight() uint32
func (*Blockchain) GetHeader ¶
func (b *Blockchain) GetHeader(hash Uint256) (*Header, error)
func (*Blockchain) GetOrphanRoot ¶
func (b *Blockchain) GetOrphanRoot(hash *Uint256) *Uint256
func (*Blockchain) GetPrevNodeFromBlock ¶
func (b *Blockchain) GetPrevNodeFromBlock(block *Block) (*BlockNode, error)
getPrevNodeFromBlock returns a block node for the block previous to the passed block (the passed block's parent). When it is already in the memory block chain, it simply returns it. Otherwise, it loads the previous block from the block database, creates a new block node from it, and returns it. The returned node will be nil if the genesis block is passed.
func (*Blockchain) GetPrevNodeFromNode ¶
func (b *Blockchain) GetPrevNodeFromNode(node *BlockNode) (*BlockNode, error)
getPrevNodeFromNode returns a block node for the block previous to the passed block node (the passed block node's parent). When the node is already connected to a parent, it simply returns it. Otherwise, it loads the associated block from the database to obtain the previous hash and uses that to dynamically create a new block node and return it. The memory block chain is updated accordingly. The returned node will be nil if the genesis block is passed.
func (*Blockchain) GetReorganizeNodes ¶
getReorganizeNodes finds the fork point between the main chain and the passed node and returns a list of block nodes that would need to be detached from the main chain and a list of block nodes that would need to be attached to the fork point (which will be the end of the main chain after detaching the returned list of block nodes) in order to reorganize the chain such that the passed node is the new end of the main chain. The lists will be empty if the passed node is not on a side chain.
func (*Blockchain) IsKnownOrphan ¶
func (b *Blockchain) IsKnownOrphan(hash *Uint256) bool
func (*Blockchain) LatestBlockLocator ¶
func (b *Blockchain) LatestBlockLocator() ([]*Uint256, error)
func (*Blockchain) LatestLocatorHash ¶
func (b *Blockchain) LatestLocatorHash(locator []*Uint256) *Uint256
func (*Blockchain) LoadBlockNode ¶
func (b *Blockchain) LoadBlockNode(blockHeader *Header, hash *Uint256) (*BlockNode, error)
func (*Blockchain) LookupNodeInIndex ¶
func (b *Blockchain) LookupNodeInIndex(hash *Uint256) (*BlockNode, bool)
func (*Blockchain) MedianAdjustedTime ¶
func (b *Blockchain) MedianAdjustedTime() time.Time
func (*Blockchain) ProcessBlock ¶
func (b *Blockchain) ProcessBlock(block *Block) (bool, bool, error)
(bool, bool, error) 1. inMainChain 2. isOphan 3. error
func (*Blockchain) ProcessOrphans ¶
func (b *Blockchain) ProcessOrphans(hash *Uint256) error
func (*Blockchain) PruneBlockNodes ¶
func (b *Blockchain) PruneBlockNodes() error
func (*Blockchain) RemoveBlockNode ¶
func (b *Blockchain) RemoveBlockNode(node *BlockNode) error
func (*Blockchain) RemoveNodeFromIndex ¶
func (b *Blockchain) RemoveNodeFromIndex(node *BlockNode)
func (*Blockchain) RemoveOrphanBlock ¶
func (b *Blockchain) RemoveOrphanBlock(orphan *OrphanBlock)
func (*Blockchain) ReorganizeChain ¶
func (b *Blockchain) ReorganizeChain(detachNodes, attachNodes *list.List) error
reorganizeChain reorganizes the block chain by disconnecting the nodes in the detachNodes list and connecting the nodes in the attach list. It expects that the lists are already in the correct order and are in sync with the end of the current best chain. Specifically, nodes that are being disconnected must be in reverse order (think of popping them off the end of the chain) and nodes the are being attached must be in forwards order (think pushing them onto the end of the chain).
func (*Blockchain) UpdateBestHeight ¶
func (b *Blockchain) UpdateBestHeight(val uint32)
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) GetAsset ¶
func (c *ChainStore) GetAsset(hash Uint256) (*Asset, error)
func (*ChainStore) GetAssets ¶
func (c *ChainStore) GetAssets() map[Uint256]*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) 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.2.0
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) InitWithGenesisBlock ¶
func (c *ChainStore) InitWithGenesisBlock(genesisBlock *Block) (uint32, 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.2.0
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 Asset) error
func (*ChainStore) PersistBlockHash ¶
func (c *ChainStore) PersistBlockHash(b *Block) error
key: DATA_BlockHash || height value: block hash
func (*ChainStore) PersistCurrentBlock ¶
func (c *ChainStore) PersistCurrentBlock(b *Block) error
key: SYS_CurrentBlock value: current block hash || height
func (*ChainStore) PersistSidechainTx ¶ added in v0.2.0
func (c *ChainStore) PersistSidechainTx(sidechainTxHash Uint256)
func (*ChainStore) PersistTransaction ¶
func (c *ChainStore) PersistTransaction(tx *Transaction, height uint32) error
func (*ChainStore) PersistTransactions ¶
func (c *ChainStore) PersistTransactions(b *Block) error
func (*ChainStore) PersistTrimmedBlock ¶
func (c *ChainStore) PersistTrimmedBlock(b *Block) error
key: DATA_Header || block hash value: sysfee(8bytes) || trimmed block
func (*ChainStore) PersistUnspend ¶
func (c *ChainStore) PersistUnspend(b *Block) error
func (*ChainStore) PersistUnspendUTXOs ¶
func (c *ChainStore) PersistUnspendUTXOs(b *Block) error
func (*ChainStore) PersistUnspentWithProgramHash ¶
func (c *ChainStore) PersistUnspentWithProgramHash(programHash Uint168, assetid Uint256, height uint32, unspents []*UTXO) error
func (*ChainStore) RemoveHeaderListElement ¶
func (c *ChainStore) RemoveHeaderListElement(hash Uint256)
func (*ChainStore) RollbackAsset ¶
func (c *ChainStore) RollbackAsset(assetID Uint256) error
func (*ChainStore) RollbackBlock ¶
func (c *ChainStore) RollbackBlock(blockHash Uint256) error
func (*ChainStore) RollbackBlockHash ¶
func (c *ChainStore) RollbackBlockHash(b *Block) error
func (*ChainStore) RollbackCurrentBlock ¶
func (c *ChainStore) RollbackCurrentBlock(b *Block) error
func (*ChainStore) RollbackSidechainTx ¶ added in v0.2.0
func (c *ChainStore) RollbackSidechainTx(sidechainTxHash Uint256) error
func (*ChainStore) RollbackTransaction ¶
func (c *ChainStore) RollbackTransaction(txn *Transaction) 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
func (*ChainStore) SaveBlock ¶
func (c *ChainStore) SaveBlock(b *Block) error
type DataEntryPrefix ¶
type DataEntryPrefix byte
DataEntryPrefix
const ( // DATA DATA_BlockHash DataEntryPrefix = 0x00 DATA_Header DataEntryPrefix = 0x01 DATA_Transaction DataEntryPrefix = 0x02 // INDEX IX_HeaderHashList DataEntryPrefix = 0x80 IX_Unspent DataEntryPrefix = 0x90 IX_Unspent_UTXO DataEntryPrefix = 0x91 IX_SideChain_Tx DataEntryPrefix = 0x92 // ASSET ST_Info DataEntryPrefix = 0xc0 //SYSTEM SYS_CurrentBlock DataEntryPrefix = 0x40 SYS_CurrentBookKeeper DataEntryPrefix = 0x42 //CONFIG CFG_Version DataEntryPrefix = 0xf0 )
type IChainStore ¶
type IChainStore interface { InitWithGenesisBlock(genesisblock *Block) (uint32, error) SaveBlock(b *Block) error GetBlock(hash Uint256) (*Block, error) GetBlockHash(height uint32) (Uint256, error) IsDoubleSpend(tx *Transaction) bool 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 Asset) error GetAsset(hash Uint256) (*Asset, error) PersistSidechainTx(sidechainTxHash Uint256) GetSidechainTx(sidechainTxHash Uint256) (byte, error) GetCurrentBlockHash() Uint256 GetHeight() uint32 RemoveHeaderListElement(hash Uint256) 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]*Asset IsTxHashDuplicate(txhash Uint256) bool IsSidechainTxHashDuplicate(sidechainTxHash Uint256) bool IsBlockInStore(hash Uint256) bool Close() }
IChainStore provides func with store package.
func NewChainStore ¶
func NewChainStore() (IChainStore, error)
type Ledger ¶
type Ledger struct { Blockchain *Blockchain Store IChainStore }
Ledger - the struct for ledger
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 ¶
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 TxPool ¶
func (*TxPool) AppendToTxnPool ¶
func (pool *TxPool) AppendToTxnPool(txn *Transaction) ErrCode
append transaction to txnpool when check ok. 1.check 2.check with ledger(db) 3.check with pool
func (*TxPool) CleanSubmittedTransactions ¶
clean the trasaction Pool with committed block.
func (*TxPool) GetTransaction ¶
func (pool *TxPool) GetTransaction(hash Uint256) *Transaction
get the transaction by hash
func (*TxPool) GetTransactionCount ¶
func (*TxPool) GetTransactionPool ¶ added in v0.2.0
get the transaction in txnpool
func (*TxPool) IsDuplicateSidechainTx ¶ added in v0.2.0
func (*TxPool) MaybeAcceptTransaction ¶
func (*TxPool) RemoveTransaction ¶
func (pool *TxPool) RemoveTransaction(txn *Transaction)