database

package
v4.8.11+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2020 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

View Source
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

func AccountIDKey(accountID string) []byte

AccountIDKey account id store prefix

func CalcGlobalTxIndex added in v0.3.0

func CalcGlobalTxIndex(blockHash *bc.Hash, position uint64) []byte

CalcGlobalTxIndex calcuate the block index + position index key

func CalcGlobalTxIndexKey added in v0.3.0

func CalcGlobalTxIndexKey(txID string) []byte

CalcGlobalTxIndexKey calculate tx hash index key

func ContractKey added in v0.3.0

func ContractKey(hash bc.Hash) []byte

ContractKey account control promgram store prefix

func ContractUTXOKey added in v0.3.0

func ContractUTXOKey(id bc.Hash) []byte

ContractUTXOKey makes a smart contract unspent outputs key to store

func GetBlockHashesByHeight added in v0.2.0

func GetBlockHashesByHeight(db dbm.DB, height uint64) ([]*bc.Hash, error)

GetBlockHashesByHeight return block hashes by given height

func GetBlockHeader

func GetBlockHeader(db dbm.DB, hash *bc.Hash) (*types.BlockHeader, error)

GetBlockHeader return the block header by given hash

func GetBlockTransactions

func GetBlockTransactions(db dbm.DB, hash *bc.Hash) ([]*types.Tx, error)

GetBlockTransactions return the block transactions by given hash

func GetConsensusResult added in v0.3.0

func GetConsensusResult(db dbm.DB, seq uint64) (*state.ConsensusResult, error)

GetConsensusResult return the vote result by given sequence

func GetMainChainHash added in v0.2.0

func GetMainChainHash(db dbm.DB, height uint64) (*bc.Hash, error)

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

func StandardUTXOKey(id bc.Hash) []byte

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) GetUTXO added in v0.3.0

func (store *AccountStore) GetUTXO(outid bc.Hash) (*acc.UTXO, error)

GetUTXO get standard utxo by id

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

func (store *AccountStore) SetStandardUTXO(outputID bc.Hash, utxo *acc.UTXO) error

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 NewStore

func NewStore(db dbm.DB) *Store

NewStore creates and returns a new Store object.

func (*Store) BlockExist

func (s *Store) BlockExist(hash *bc.Hash) bool

BlockExist check if the block is stored in disk

func (*Store) DeleteBlock added in v1.1.0

func (s *Store) DeleteBlock(block *types.Block) error

DeleteBlock delete a new block in the protocol.

func (*Store) DeleteConsensusResult added in v1.1.0

func (s *Store) DeleteConsensusResult(seq uint64) error

DeleteConsensusResult delete a consensusResult from cache and database

func (*Store) GetBlock

func (s *Store) GetBlock(hash *bc.Hash) (*types.Block, error)

GetBlock return the block by given hash

func (*Store) GetBlockHashesByHeight added in v0.2.0

func (s *Store) GetBlockHashesByHeight(height uint64) ([]*bc.Hash, error)

GetBlockHashesByHeight return the block hash by the specified height

func (*Store) GetBlockHeader

func (s *Store) GetBlockHeader(hash *bc.Hash) (*types.BlockHeader, error)

GetBlockHeader return the BlockHeader by given hash

func (*Store) GetBlockTransactions

func (s *Store) GetBlockTransactions(hash *bc.Hash) ([]*types.Tx, error)

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

func (s *Store) GetMainChainHash(height uint64) (*bc.Hash, error)

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

func (s *Store) GetTransactionStatus(hash *bc.Hash) (*bc.TransactionStatus, error)

GetTransactionStatus will return the utxo that related to the block hash

func (*Store) GetTransactionsUtxo

func (s *Store) GetTransactionsUtxo(view *state.UtxoViewpoint, txs []*bc.Tx) error

GetTransactionsUtxo will return all the utxo that related to the input txs

func (*Store) GetUtxo

func (s *Store) GetUtxo(hash *bc.Hash) (*storage.UtxoEntry, error)

GetUtxo will search the utxo in db

func (*Store) SaveBlock

func (s *Store) SaveBlock(block *types.Block, ts *bc.TransactionStatus) error

SaveBlock persists a new block in the protocol.

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) GetAsset added in v0.3.0

func (store *WalletStore) GetAsset(assetID *bc.AssetID) (*asset.Asset, error)

GetAsset get asset by assetID

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

func (store *WalletStore) GetStandardUTXO(outid bc.Hash) (*acc.UTXO, error)

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

func (store *WalletStore) ListAccountUTXOs(id string, isSmartContract bool) ([]*acc.UTXO, error)

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

func (store *WalletStore) SetContractUTXO(outputID bc.Hash, utxo *acc.UTXO) error

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

Directories

Path Synopsis
Package storage is a generated protocol buffer package.
Package storage is a generated protocol buffer package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL