Documentation ¶
Index ¶
- Variables
- func AccountIDKey(accountID string) []byte
- func CalcGlobalTxIndex(blockHash *bc.Hash, position uint64) []byte
- func CalcGlobalTxIndexKey(txID string) []byte
- func ContractKey(hash bc.Hash) []byte
- func ContractUTXOKey(id bc.Hash) []byte
- func GetBlockHashesByHeight(db dbm.DB, height uint64) ([]*bc.Hash, error)
- func GetBlockHeader(db dbm.DB, hash *bc.Hash) (*types.BlockHeader, error)
- func GetBlockTransactions(db dbm.DB, hash *bc.Hash) ([]*types.Tx, error)
- func GetConsensusResult(db dbm.DB, seq uint64) (*state.ConsensusResult, error)
- func GetMainChainHash(db dbm.DB, height uint64) (*bc.Hash, error)
- func SaveUtxoView(batch dbm.Batch, view *state.UtxoViewpoint) error
- func StandardUTXOKey(id bc.Hash) []byte
- type AccountStore
- func (store *AccountStore) CommitBatch() error
- func (store *AccountStore) DeleteAccount(account *acc.Account) error
- func (store *AccountStore) DeleteStandardUTXO(outputID bc.Hash)
- func (store *AccountStore) GetAccountByAlias(accountAlias string) (*acc.Account, error)
- func (store *AccountStore) GetAccountByID(accountID string) (*acc.Account, error)
- func (store *AccountStore) GetAccountIndex(xpubs []chainkd.XPub) uint64
- func (store *AccountStore) GetBip44ContractIndex(accountID string, change bool) uint64
- func (store *AccountStore) GetCoinbaseArbitrary() []byte
- func (store *AccountStore) GetContractIndex(accountID string) uint64
- func (store *AccountStore) GetControlProgram(hash bc.Hash) (*acc.CtrlProgram, error)
- func (store *AccountStore) GetMiningAddress() (*acc.CtrlProgram, error)
- func (store *AccountStore) GetUTXO(outid bc.Hash) (*acc.UTXO, error)
- func (store *AccountStore) InitBatch() acc.AccountStore
- func (store *AccountStore) ListAccounts(id string) ([]*acc.Account, error)
- func (store *AccountStore) ListControlPrograms() ([]*acc.CtrlProgram, error)
- func (store *AccountStore) ListUTXOs() ([]*acc.UTXO, error)
- func (store *AccountStore) SetAccount(account *acc.Account) error
- func (store *AccountStore) SetAccountIndex(account *acc.Account)
- func (store *AccountStore) SetBip44ContractIndex(accountID string, change bool, index uint64)
- func (store *AccountStore) SetCoinbaseArbitrary(arbitrary []byte)
- func (store *AccountStore) SetContractIndex(accountID string, index uint64)
- func (store *AccountStore) SetControlProgram(hash bc.Hash, program *acc.CtrlProgram) error
- func (store *AccountStore) SetMiningAddress(program *acc.CtrlProgram) error
- func (store *AccountStore) SetStandardUTXO(outputID bc.Hash, utxo *acc.UTXO) error
- type Store
- func (s *Store) BlockExist(hash *bc.Hash) bool
- func (s *Store) DeleteBlock(block *types.Block) error
- func (s *Store) DeleteConsensusResult(seq uint64) error
- func (s *Store) GetBlock(hash *bc.Hash) (*types.Block, error)
- func (s *Store) GetBlockHashesByHeight(height uint64) ([]*bc.Hash, error)
- func (s *Store) GetBlockHeader(hash *bc.Hash) (*types.BlockHeader, error)
- func (s *Store) GetBlockTransactions(hash *bc.Hash) ([]*types.Tx, error)
- func (s *Store) GetConsensusResult(seq uint64) (*state.ConsensusResult, error)
- func (s *Store) GetMainChainHash(height uint64) (*bc.Hash, error)
- func (s *Store) GetStoreStatus() *protocol.BlockStoreState
- func (s *Store) GetTransactionStatus(hash *bc.Hash) (*bc.TransactionStatus, error)
- func (s *Store) GetTransactionsUtxo(view *state.UtxoViewpoint, txs []*bc.Tx) error
- func (s *Store) GetUtxo(hash *bc.Hash) (*storage.UtxoEntry, error)
- func (s *Store) SaveBlock(block *types.Block, ts *bc.TransactionStatus) error
- func (s *Store) SaveBlockHeader(blockHeader *types.BlockHeader) error
- func (s *Store) SaveChainStatus(blockHeader, irrBlockHeader *types.BlockHeader, ...) error
- type WalletStore
- func (store *WalletStore) CommitBatch() error
- func (store *WalletStore) DeleteContractUTXO(outputID bc.Hash)
- func (store *WalletStore) DeleteRecoveryStatus()
- func (store *WalletStore) DeleteTransactions(height uint64)
- func (store *WalletStore) DeleteUnconfirmedTransaction(txID string)
- func (store *WalletStore) DeleteWalletTransactions()
- func (store *WalletStore) DeleteWalletUTXOs()
- func (store *WalletStore) GetAsset(assetID *bc.AssetID) (*asset.Asset, error)
- func (store *WalletStore) GetGlobalTransactionIndex(txID string) []byte
- func (store *WalletStore) GetRecoveryStatus() (*wallet.RecoveryState, error)
- func (store *WalletStore) GetStandardUTXO(outid bc.Hash) (*acc.UTXO, error)
- func (store *WalletStore) GetTransaction(txID string) (*query.AnnotatedTx, error)
- func (store *WalletStore) GetUnconfirmedTransaction(txID string) (*query.AnnotatedTx, error)
- func (store *WalletStore) GetWalletInfo() (*wallet.StatusInfo, error)
- func (store *WalletStore) InitBatch() wallet.WalletStore
- func (store *WalletStore) ListAccountUTXOs(id string, isSmartContract bool) ([]*acc.UTXO, error)
- func (store *WalletStore) ListTransactions(accountID string, StartTxID string, count uint, unconfirmed bool) ([]*query.AnnotatedTx, error)
- func (store *WalletStore) ListUnconfirmedTransactions() ([]*query.AnnotatedTx, error)
- func (store *WalletStore) SetAssetDefinition(assetID *bc.AssetID, definition []byte)
- func (store *WalletStore) SetContractUTXO(outputID bc.Hash, utxo *acc.UTXO) error
- func (store *WalletStore) SetGlobalTransactionIndex(globalTxID string, blockHash *bc.Hash, position uint64)
- func (store *WalletStore) SetRecoveryStatus(recoveryState *wallet.RecoveryState) error
- func (store *WalletStore) SetTransaction(height uint64, tx *query.AnnotatedTx) error
- func (store *WalletStore) SetUnconfirmedTransaction(txID string, tx *query.AnnotatedTx) error
- func (store *WalletStore) SetWalletInfo(status *wallet.StatusInfo) error
Constants ¶
This section is empty.
Variables ¶
var ( UTXOPrefix = append(accountStore, utxoPrefix, colon) ContractPrefix = append(accountStore, contractPrefix, colon) ContractIndexPrefix = append(accountStore, contractIndexPrefix, colon) AccountPrefix = append(accountStore, accountPrefix, colon) // AccountPrefix is account ID prefix AccountIndexPrefix = append(accountStore, accountIndexPrefix, colon) )
leveldb key prefix
var ( SUTXOPrefix = append(walletStore, sutxoPrefix, colon) AccountAliasPrefix = append(walletStore, accountAliasPrefix, colon) TxPrefix = append(walletStore, txPrefix, colon) //TxPrefix is wallet database transactions prefix TxIndexPrefix = append(walletStore, txIndexPrefix, colon) //TxIndexPrefix is wallet database tx index prefix UnconfirmedTxPrefix = append(walletStore, unconfirmedTxPrefix, colon) //UnconfirmedTxPrefix is txpool unconfirmed transactions prefix GlobalTxIndexPrefix = append(walletStore, globalTxIndexPrefix, colon) //GlobalTxIndexPrefix is wallet database global tx index prefix WalletKey = append(walletStore, walletKey) MiningAddressKey = append(walletStore, miningAddressKey) CoinbaseAbKey = append(walletStore, coinbaseAbKey) RecoveryKey = append(walletStore, recoveryKey) )
pre-define variables
Functions ¶
func AccountIDKey ¶ added in v0.3.0
AccountIDKey account id store prefix
func CalcGlobalTxIndex ¶ added in v0.3.0
CalcGlobalTxIndex calcuate the block index + position index key
func CalcGlobalTxIndexKey ¶ added in v0.3.0
CalcGlobalTxIndexKey calculate tx hash index key
func ContractKey ¶ added in v0.3.0
ContractKey account control promgram store prefix
func ContractUTXOKey ¶ added in v0.3.0
ContractUTXOKey makes a smart contract unspent outputs key to store
func GetBlockHashesByHeight ¶ added in v0.2.0
GetBlockHashesByHeight return block hashes by given height
func GetBlockHeader ¶
GetBlockHeader return the block header by given hash
func GetBlockTransactions ¶
GetBlockTransactions return the block transactions by given hash
func GetConsensusResult ¶ added in v0.3.0
GetConsensusResult return the vote result by given sequence
func GetMainChainHash ¶ added in v0.2.0
GetMainChainHash return BlockHash by given height
func SaveUtxoView ¶
func SaveUtxoView(batch dbm.Batch, view *state.UtxoViewpoint) error
SaveUtxoView is export for intergation test
func StandardUTXOKey ¶ added in v0.3.0
StandardUTXOKey makes an account unspent outputs key to store
Types ¶
type AccountStore ¶ added in v0.3.0
type AccountStore struct {
// contains filtered or unexported fields
}
AccountStore satisfies AccountStore interface.
func NewAccountStore ¶ added in v0.3.0
func NewAccountStore(db dbm.DB) *AccountStore
NewAccountStore create new AccountStore.
func (*AccountStore) CommitBatch ¶ added in v0.3.0
func (store *AccountStore) CommitBatch() error
CommitBatch commit batch
func (*AccountStore) DeleteAccount ¶ added in v0.3.0
func (store *AccountStore) DeleteAccount(account *acc.Account) error
DeleteAccount set account account ID, account alias and raw account.
func (*AccountStore) DeleteStandardUTXO ¶ added in v0.3.0
func (store *AccountStore) DeleteStandardUTXO(outputID bc.Hash)
DeleteStandardUTXO delete utxo by outpu id
func (*AccountStore) GetAccountByAlias ¶ added in v0.3.0
func (store *AccountStore) GetAccountByAlias(accountAlias string) (*acc.Account, error)
GetAccountByAlias get account by account alias
func (*AccountStore) GetAccountByID ¶ added in v0.3.0
func (store *AccountStore) GetAccountByID(accountID string) (*acc.Account, error)
GetAccountByID get account by accountID
func (*AccountStore) GetAccountIndex ¶ added in v0.3.0
func (store *AccountStore) GetAccountIndex(xpubs []chainkd.XPub) uint64
GetAccountIndex get account index by account xpubs
func (*AccountStore) GetBip44ContractIndex ¶ added in v0.3.0
func (store *AccountStore) GetBip44ContractIndex(accountID string, change bool) uint64
GetBip44ContractIndex get bip44 contract index
func (*AccountStore) GetCoinbaseArbitrary ¶ added in v0.3.0
func (store *AccountStore) GetCoinbaseArbitrary() []byte
GetCoinbaseArbitrary get coinbase arbitrary
func (*AccountStore) GetContractIndex ¶ added in v0.3.0
func (store *AccountStore) GetContractIndex(accountID string) uint64
GetContractIndex get contract index
func (*AccountStore) GetControlProgram ¶ added in v0.3.0
func (store *AccountStore) GetControlProgram(hash bc.Hash) (*acc.CtrlProgram, error)
GetControlProgram get control program
func (*AccountStore) GetMiningAddress ¶ added in v0.3.0
func (store *AccountStore) GetMiningAddress() (*acc.CtrlProgram, error)
GetMiningAddress get mining address
func (*AccountStore) InitBatch ¶ added in v0.3.0
func (store *AccountStore) InitBatch() acc.AccountStore
InitBatch initial new account store
func (*AccountStore) ListAccounts ¶ added in v0.3.0
func (store *AccountStore) ListAccounts(id string) ([]*acc.Account, error)
ListAccounts get all accounts which name prfix is id.
func (*AccountStore) ListControlPrograms ¶ added in v0.3.0
func (store *AccountStore) ListControlPrograms() ([]*acc.CtrlProgram, error)
ListControlPrograms get all local control programs
func (*AccountStore) ListUTXOs ¶ added in v0.3.0
func (store *AccountStore) ListUTXOs() ([]*acc.UTXO, error)
ListUTXOs list all utxos
func (*AccountStore) SetAccount ¶ added in v0.3.0
func (store *AccountStore) SetAccount(account *acc.Account) error
SetAccount set account account ID, account alias and raw account.
func (*AccountStore) SetAccountIndex ¶ added in v0.3.0
func (store *AccountStore) SetAccountIndex(account *acc.Account)
SetAccountIndex update account index
func (*AccountStore) SetBip44ContractIndex ¶ added in v0.3.0
func (store *AccountStore) SetBip44ContractIndex(accountID string, change bool, index uint64)
SetBip44ContractIndex set contract index
func (*AccountStore) SetCoinbaseArbitrary ¶ added in v0.3.0
func (store *AccountStore) SetCoinbaseArbitrary(arbitrary []byte)
SetCoinbaseArbitrary set coinbase arbitrary
func (*AccountStore) SetContractIndex ¶ added in v0.3.0
func (store *AccountStore) SetContractIndex(accountID string, index uint64)
SetContractIndex set contract index
func (*AccountStore) SetControlProgram ¶ added in v0.3.0
func (store *AccountStore) SetControlProgram(hash bc.Hash, program *acc.CtrlProgram) error
SetControlProgram set raw program
func (*AccountStore) SetMiningAddress ¶ added in v0.3.0
func (store *AccountStore) SetMiningAddress(program *acc.CtrlProgram) error
SetMiningAddress set mining address
func (*AccountStore) SetStandardUTXO ¶ added in v0.3.0
SetStandardUTXO set standard utxo
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
A Store encapsulates storage for blockchain validation. It satisfies the interface protocol.Store, and provides additional methods for querying current data.
func (*Store) BlockExist ¶
BlockExist check if the block is stored in disk
func (*Store) DeleteBlock ¶ added in v1.1.0
DeleteBlock delete a new block in the protocol.
func (*Store) DeleteConsensusResult ¶ added in v1.1.0
DeleteConsensusResult delete a consensusResult from cache and database
func (*Store) GetBlockHashesByHeight ¶ added in v0.2.0
GetBlockHashesByHeight return the block hash by the specified height
func (*Store) GetBlockHeader ¶
GetBlockHeader return the BlockHeader by given hash
func (*Store) GetBlockTransactions ¶
GetBlockTransactions return the Block transactions by given hash
func (*Store) GetConsensusResult ¶ added in v0.3.0
func (s *Store) GetConsensusResult(seq uint64) (*state.ConsensusResult, error)
GetConsensusResult retrive the voting result in specified vote sequence
func (*Store) GetMainChainHash ¶ added in v0.2.0
GetMainChainHash return the block hash by the specified height
func (*Store) GetStoreStatus ¶
func (s *Store) GetStoreStatus() *protocol.BlockStoreState
GetStoreStatus return the BlockStoreStateJSON
func (*Store) GetTransactionStatus ¶
GetTransactionStatus will return the utxo that related to the block hash
func (*Store) GetTransactionsUtxo ¶
GetTransactionsUtxo will return all the utxo that related to the input txs
func (*Store) SaveBlockHeader ¶
func (s *Store) SaveBlockHeader(blockHeader *types.BlockHeader) error
SaveBlockHeader persists a new block header in the protocol.
func (*Store) SaveChainStatus ¶
func (s *Store) SaveChainStatus(blockHeader, irrBlockHeader *types.BlockHeader, mainBlockHeaders []*types.BlockHeader, view *state.UtxoViewpoint, consensusResults []*state.ConsensusResult) error
SaveChainStatus save the core's newest status && delete old status
type WalletStore ¶ added in v0.3.0
type WalletStore struct {
// contains filtered or unexported fields
}
WalletStore store wallet using leveldb
func NewWalletStore ¶ added in v0.3.0
func NewWalletStore(db dbm.DB) *WalletStore
NewWalletStore create new WalletStore struct
func (*WalletStore) CommitBatch ¶ added in v0.3.0
func (store *WalletStore) CommitBatch() error
CommitBatch commit batch
func (*WalletStore) DeleteContractUTXO ¶ added in v0.3.0
func (store *WalletStore) DeleteContractUTXO(outputID bc.Hash)
DeleteContractUTXO delete contract utxo by outputID
func (*WalletStore) DeleteRecoveryStatus ¶ added in v0.3.0
func (store *WalletStore) DeleteRecoveryStatus()
DeleteRecoveryStatus delete recovery status
func (*WalletStore) DeleteTransactions ¶ added in v0.3.0
func (store *WalletStore) DeleteTransactions(height uint64)
DeleteTransactions delete transactions when orphan block rollback
func (*WalletStore) DeleteUnconfirmedTransaction ¶ added in v0.3.0
func (store *WalletStore) DeleteUnconfirmedTransaction(txID string)
DeleteUnconfirmedTransaction delete unconfirmed tx by txID
func (*WalletStore) DeleteWalletTransactions ¶ added in v0.3.0
func (store *WalletStore) DeleteWalletTransactions()
DeleteWalletTransactions delete all txs in wallet
func (*WalletStore) DeleteWalletUTXOs ¶ added in v0.3.0
func (store *WalletStore) DeleteWalletUTXOs()
DeleteWalletUTXOs delete all utxos in wallet
func (*WalletStore) GetGlobalTransactionIndex ¶ added in v0.3.0
func (store *WalletStore) GetGlobalTransactionIndex(txID string) []byte
GetGlobalTransactionIndex get global tx by txID
func (*WalletStore) GetRecoveryStatus ¶ added in v0.3.0
func (store *WalletStore) GetRecoveryStatus() (*wallet.RecoveryState, error)
GetRecoveryStatus delete recovery status
func (*WalletStore) GetStandardUTXO ¶ added in v0.3.0
GetStandardUTXO get standard utxo by id
func (*WalletStore) GetTransaction ¶ added in v0.3.0
func (store *WalletStore) GetTransaction(txID string) (*query.AnnotatedTx, error)
GetTransaction get tx by txid
func (*WalletStore) GetUnconfirmedTransaction ¶ added in v0.3.0
func (store *WalletStore) GetUnconfirmedTransaction(txID string) (*query.AnnotatedTx, error)
GetUnconfirmedTransaction get unconfirmed tx by txID
func (*WalletStore) GetWalletInfo ¶ added in v0.3.0
func (store *WalletStore) GetWalletInfo() (*wallet.StatusInfo, error)
GetWalletInfo get wallet information
func (*WalletStore) InitBatch ¶ added in v0.3.0
func (store *WalletStore) InitBatch() wallet.WalletStore
InitBatch initial new wallet store
func (*WalletStore) ListAccountUTXOs ¶ added in v0.3.0
ListAccountUTXOs get all account unspent outputs
func (*WalletStore) ListTransactions ¶ added in v0.3.0
func (store *WalletStore) ListTransactions(accountID string, StartTxID string, count uint, unconfirmed bool) ([]*query.AnnotatedTx, error)
ListTransactions list tx by filter args
func (*WalletStore) ListUnconfirmedTransactions ¶ added in v0.3.0
func (store *WalletStore) ListUnconfirmedTransactions() ([]*query.AnnotatedTx, error)
ListUnconfirmedTransactions get all unconfirmed txs
func (*WalletStore) SetAssetDefinition ¶ added in v0.3.0
func (store *WalletStore) SetAssetDefinition(assetID *bc.AssetID, definition []byte)
SetAssetDefinition set assetID and definition
func (*WalletStore) SetContractUTXO ¶ added in v0.3.0
SetContractUTXO set standard utxo
func (*WalletStore) SetGlobalTransactionIndex ¶ added in v0.3.0
func (store *WalletStore) SetGlobalTransactionIndex(globalTxID string, blockHash *bc.Hash, position uint64)
SetGlobalTransactionIndex set global tx index by blockhash and position
func (*WalletStore) SetRecoveryStatus ¶ added in v0.3.0
func (store *WalletStore) SetRecoveryStatus(recoveryState *wallet.RecoveryState) error
SetRecoveryStatus set recovery status
func (*WalletStore) SetTransaction ¶ added in v0.3.0
func (store *WalletStore) SetTransaction(height uint64, tx *query.AnnotatedTx) error
SetTransaction set raw transaction by block height and tx position
func (*WalletStore) SetUnconfirmedTransaction ¶ added in v0.3.0
func (store *WalletStore) SetUnconfirmedTransaction(txID string, tx *query.AnnotatedTx) error
SetUnconfirmedTransaction set unconfirmed tx by txID
func (*WalletStore) SetWalletInfo ¶ added in v0.3.0
func (store *WalletStore) SetWalletInfo(status *wallet.StatusInfo) error
SetWalletInfo get wallet information