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(txn *Transaction) 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 CheckTransactionBalance(tx *Transaction) error
- func CheckTransactionContext(txn *Transaction) ErrCode
- 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(txn *Transaction) error
- func CheckTransactionSize(txn *Transaction) error
- func CheckTransactionUTXOLock(txn *Transaction) error
- func CheckTransferCrossChainAssetTransaction(txn *Transaction) error
- func CheckWithdrawFromSideChainTransaction(txn *Transaction) error
- func CompactToBig(compact uint32) *big.Int
- func DumpBlockNode(node *BlockNode)
- func GetBlockRewardAmount(height uint32) common.Fixed64
- 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) ([]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)
- func ToByteArray(source []uint16) []byte
- func VerifySignature(tx *Transaction) error
- type BlockNode
- type Blockchain
- func (bc *Blockchain) AddBlock(block *Block) (bool, bool, error)
- func (b *Blockchain) AddNodeToIndex(node *BlockNode)
- func (bc *Blockchain) AddOrphanBlock(block *Block)
- func (bc *Blockchain) BlockExists(hash *Uint256) bool
- func (b *Blockchain) BlockLocatorFromHash(inhash *Uint256) []*Uint256
- func (bc *Blockchain) ConnectBestChain(node *BlockNode, block *Block) (bool, error)
- func (bc *Blockchain) ConnectBlock(node *BlockNode, block *Block) error
- func (bc *Blockchain) ContainsTransaction(hash Uint256) bool
- func (bc *Blockchain) CurrentBlockHash() Uint256
- func (bc *Blockchain) DisconnectBlock(node *BlockNode, block *Block) error
- func (bc *Blockchain) DumpState()
- func (bc *Blockchain) GetBestHeight() uint32
- func (bc *Blockchain) GetHeader(hash Uint256) (*Header, error)
- func (bc *Blockchain) GetOrphanRoot(hash *Uint256) *Uint256
- func (bc *Blockchain) GetPrevNodeFromBlock(block *Block) (*BlockNode, error)
- func (bc *Blockchain) GetPrevNodeFromNode(node *BlockNode) (*BlockNode, error)
- func (bc *Blockchain) GetReorganizeNodes(node *BlockNode) (*list.List, *list.List)
- func (bc *Blockchain) IsKnownOrphan(hash *Uint256) bool
- func (b *Blockchain) LatestBlockLocator() ([]*Uint256, error)
- func (b *Blockchain) LatestLocatorHash(locator []*Uint256) *Uint256
- func (bc *Blockchain) LoadBlockNode(blockHeader *Header, hash *Uint256) (*BlockNode, error)
- func (b *Blockchain) LookupNodeInIndex(hash *Uint256) (*BlockNode, bool)
- func (b *Blockchain) MedianAdjustedTime() time.Time
- func (bc *Blockchain) ProcessBlock(block *Block) (bool, bool, error)
- func (bc *Blockchain) ProcessOrphans(hash *Uint256) error
- func (bc *Blockchain) PruneBlockNodes() error
- func (bc *Blockchain) RemoveBlockNode(node *BlockNode) error
- func (b *Blockchain) RemoveNodeFromIndex(node *BlockNode)
- func (bc *Blockchain) RemoveOrphanBlock(orphan *OrphanBlock)
- func (bc *Blockchain) ReorganizeChain(detachNodes, attachNodes *list.List) error
- func (bc *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 (self *LevelDB) BatchCommit() error
- func (self *LevelDB) BatchDelete(key []byte)
- func (self *LevelDB) BatchPut(key []byte, value []byte)
- func (self *LevelDB) Close() error
- func (self *LevelDB) Delete(key []byte) error
- func (self *LevelDB) Get(key []byte) ([]byte, error)
- func (self *LevelDB) NewBatch()
- func (self *LevelDB) NewIterator(prefix []byte) IIterator
- func (self *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 = 3300 * 10000 * 100000000 BlockGenerateInterval = int64(config.Parameters.ChainParam.TargetTimePerBlock / time.Second) GeneratedBlocksPerYear = 365 * 24 * 60 * 60 / BlockGenerateInterval IssuancePerYear = func(totalAmount int64) float64 { return float64(totalAmount) * 4 / 100 } )
var FoundationAddress 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(txn *Transaction) error
func CheckDuplicateSidechainTx ¶ added in v0.1.1
func CheckDuplicateSidechainTx(txn *Transaction) error
validate the transaction of duplicate sidechain transaction
func CheckOutputProgramHash ¶ added in v0.1.1
func CheckOutputProgramHash(programHash Uint168) bool
func CheckProofOfWork ¶
func CheckSideChainPowConsensus ¶ added in v0.1.1
func CheckTransactionBalance ¶
func CheckTransactionBalance(tx *Transaction) error
func CheckTransactionContext ¶
func CheckTransactionContext(txn *Transaction) ErrCode
CheckTransactionContext verifys a transaction with history transaction in ledger
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(txn *Transaction) error
func CheckTransactionSize ¶
func CheckTransactionSize(txn *Transaction) error
func CheckTransactionUTXOLock ¶
func CheckTransactionUTXOLock(txn *Transaction) error
func CheckTransferCrossChainAssetTransaction ¶ added in v0.1.1
func CheckTransferCrossChainAssetTransaction(txn *Transaction) error
func CheckWithdrawFromSideChainTransaction ¶ added in v0.1.1
func CheckWithdrawFromSideChainTransaction(txn *Transaction) error
func CompactToBig ¶
func DumpBlockNode ¶
func DumpBlockNode(node *BlockNode)
func GetBlockRewardAmount ¶ added in v0.1.1
func GetCurrentArbiter ¶ added in v0.1.1
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.1.1
func SortPrograms(programs []*Program)
func ToByteArray ¶
func VerifySignature ¶
func VerifySignature(tx *Transaction) error
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 (bc *Blockchain) AddOrphanBlock(block *Block)
func (*Blockchain) BlockExists ¶
func (bc *Blockchain) BlockExists(hash *Uint256) bool
func (*Blockchain) BlockLocatorFromHash ¶
func (b *Blockchain) BlockLocatorFromHash(inhash *Uint256) []*Uint256
func (*Blockchain) ConnectBestChain ¶
func (bc *Blockchain) ConnectBestChain(node *BlockNode, block *Block) (bool, error)
func (*Blockchain) ConnectBlock ¶
func (bc *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 (bc *Blockchain) ContainsTransaction(hash Uint256) bool
func (*Blockchain) CurrentBlockHash ¶
func (bc *Blockchain) CurrentBlockHash() Uint256
func (*Blockchain) DisconnectBlock ¶
func (bc *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 (bc *Blockchain) DumpState()
func (*Blockchain) GetBestHeight ¶
func (bc *Blockchain) GetBestHeight() uint32
func (*Blockchain) GetHeader ¶
func (bc *Blockchain) GetHeader(hash Uint256) (*Header, error)
func (*Blockchain) GetOrphanRoot ¶
func (bc *Blockchain) GetOrphanRoot(hash *Uint256) *Uint256
func (*Blockchain) GetPrevNodeFromBlock ¶
func (bc *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 (bc *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 (bc *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 (bc *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 (bc *Blockchain) ProcessBlock(block *Block) (bool, bool, error)
(bool, bool, error) 1. inMainChain 2. isOphan 3. error
func (*Blockchain) ProcessOrphans ¶
func (bc *Blockchain) ProcessOrphans(hash *Uint256) error
func (*Blockchain) PruneBlockNodes ¶
func (bc *Blockchain) PruneBlockNodes() error
func (*Blockchain) RemoveBlockNode ¶
func (bc *Blockchain) RemoveBlockNode(node *BlockNode) error
func (*Blockchain) RemoveNodeFromIndex ¶
func (b *Blockchain) RemoveNodeFromIndex(node *BlockNode)
func (*Blockchain) RemoveOrphanBlock ¶
func (bc *Blockchain) RemoveOrphanBlock(orphan *OrphanBlock)
func (*Blockchain) ReorganizeChain ¶
func (bc *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 (bc *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.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) 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.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 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.1.1
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.1.1
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.1.1
get the transaction in txnpool
func (*TxPool) IsDuplicateSidechainTx ¶ added in v0.1.1
func (*TxPool) MaybeAcceptTransaction ¶
func (*TxPool) RemoveTransaction ¶
func (pool *TxPool) RemoveTransaction(txn *Transaction)