From: Chengcheng Zhang <943420582@qq.com> Date: Sat, 29 Jun 2019 05:42:07 +0000 (+0800) Subject: update listutxos X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=d5e2ac1a25a82bb9a8abca6ed6ad56b5f6d24528;p=bytom%2Fvapor.git update listutxos --- diff --git a/account/accounts.go b/account/accounts.go index f134d365..4dcd4b2c 100644 --- a/account/accounts.go +++ b/account/accounts.go @@ -417,7 +417,7 @@ func (m *Manager) GetCoinbaseCtrlProgram() (*CtrlProgram, error) { } account := new(Account) - accounts, err := m.store.GetAccounts("") + accounts, err := m.store.ListAccounts("") if err != nil { return nil, err } @@ -484,12 +484,12 @@ func (m *Manager) IsLocalControlProgram(prog []byte) bool { // ListAccounts will return the accounts in the db func (m *Manager) ListAccounts(id string) ([]*Account, error) { - return m.store.GetAccounts(id) + return m.store.ListAccounts(id) } // ListControlProgram return all the local control program func (m *Manager) ListControlProgram() ([]*CtrlProgram, error) { - return m.store.GetControlPrograms() + return m.store.ListControlPrograms() } func (m *Manager) ListUnconfirmedUtxo(accountID string, isSmartContract bool) []*UTXO { diff --git a/account/image.go b/account/image.go index 62ce4492..6ad76570 100644 --- a/account/image.go +++ b/account/image.go @@ -25,7 +25,7 @@ func (m *Manager) Backup() (*Image, error) { Slice: []*ImageSlice{}, } - accounts, err := m.store.GetAccounts("") + accounts, err := m.store.ListAccounts("") if err != nil { return nil, err } diff --git a/account/store.go b/account/store.go index 820f75ab..70072848 100644 --- a/account/store.go +++ b/account/store.go @@ -29,12 +29,12 @@ type AccountStorer interface { SetMiningAddress(*CtrlProgram) error GetBip44ContractIndex(string, bool) uint64 GetControlProgram(common.Hash) (*CtrlProgram, error) - GetAccounts(string) ([]*Account, error) - GetControlPrograms() ([]*CtrlProgram, error) + ListAccounts(string) ([]*Account, error) + ListControlPrograms() ([]*CtrlProgram, error) SetControlProgram(common.Hash, *CtrlProgram) error SetContractIndex(string, uint64) SetBip44ContractIndex(string, bool, uint64) - GetUTXOs() []*UTXO + ListUTXOs() []*UTXO GetUTXO(bc.Hash) (*UTXO, error) SetStandardUTXO(bc.Hash, *UTXO) error } diff --git a/account/utxo_keeper.go b/account/utxo_keeper.go index 57d5d681..db2abf15 100644 --- a/account/utxo_keeper.go +++ b/account/utxo_keeper.go @@ -219,7 +219,7 @@ func (uk *utxoKeeper) findUtxos(accountID string, assetID *bc.AssetID, useUnconf } } - UTXOs := uk.store.GetUTXOs() + UTXOs := uk.store.ListUTXOs() for _, UTXO := range UTXOs { appendUtxo(UTXO) } diff --git a/database/account_store.go b/database/account_store.go index f1f8bf01..8074fb5a 100644 --- a/database/account_store.go +++ b/database/account_store.go @@ -275,8 +275,8 @@ func (store *AccountStore) GetControlProgram(hash common.Hash) (*acc.CtrlProgram return cp, nil } -// GetAccounts get all accounts which name prfix is id. -func (store *AccountStore) GetAccounts(id string) ([]*acc.Account, error) { +// ListAccounts get all accounts which name prfix is id. +func (store *AccountStore) ListAccounts(id string) ([]*acc.Account, error) { accounts := []*acc.Account{} accountIter := store.accountDB.IteratorPrefix(AccountIDKey(strings.TrimSpace(id))) defer accountIter.Release() @@ -291,8 +291,8 @@ func (store *AccountStore) GetAccounts(id string) ([]*acc.Account, error) { return accounts, nil } -// GetControlPrograms get all local control programs -func (store *AccountStore) GetControlPrograms() ([]*acc.CtrlProgram, error) { +// ListControlPrograms get all local control programs +func (store *AccountStore) ListControlPrograms() ([]*acc.CtrlProgram, error) { cps := []*acc.CtrlProgram{} cpIter := store.accountDB.IteratorPrefix([]byte(ContractPrefix)) defer cpIter.Release() @@ -339,8 +339,8 @@ func (store *AccountStore) SetBip44ContractIndex(accountID string, change bool, } } -// GetUTXOs get utxos by accountID -func (store *AccountStore) GetUTXOs() []*acc.UTXO { +// ListUTXOs get utxos by accountID +func (store *AccountStore) ListUTXOs() []*acc.UTXO { utxoIter := store.accountDB.IteratorPrefix([]byte(UTXOPrefix)) defer utxoIter.Release() diff --git a/database/wallet_store.go b/database/wallet_store.go index 4b6ac0c1..9add00b4 100644 --- a/database/wallet_store.go +++ b/database/wallet_store.go @@ -505,8 +505,8 @@ func (store *WalletStore) DeleteWalletUTXOs() { } } -// GetAccountUTXOs get all account unspent outputs -func (store *WalletStore) GetAccountUTXOs(key string) ([]*acc.UTXO, error) { +// ListAccountUTXOs get all account unspent outputs +func (store *WalletStore) ListAccountUTXOs(key string) ([]*acc.UTXO, error) { accountUtxoIter := store.walletDB.IteratorPrefix([]byte(key)) defer accountUtxoIter.Release() diff --git a/test/mock/UTXO.go b/test/mock/UTXO.go index b7e1e152..079c3d87 100644 --- a/test/mock/UTXO.go +++ b/test/mock/UTXO.go @@ -165,7 +165,7 @@ func (uk *UTXOKeeper) FindUtxos(accountID string, assetID *bc.AssetID, useUnconf } } - UTXOs := uk.Store.GetUTXOs() + UTXOs := uk.Store.ListUTXOs() for _, UTXO := range UTXOs { appendUtxo(UTXO) } diff --git a/wallet/store.go b/wallet/store.go index 3d7cce35..88ea8082 100644 --- a/wallet/store.go +++ b/wallet/store.go @@ -35,7 +35,7 @@ type WalletStorer interface { SetWalletInfo([]byte) // need move database.NewWalletStore in wallet package DeleteWalletTransactions() DeleteWalletUTXOs() - GetAccountUTXOs(string) ([]*acc.UTXO, error) + ListAccountUTXOs(string) ([]*acc.UTXO, error) SetRecoveryStatus([]byte, []byte) // recoveryManager.state isn't exported outside DeleteRecoveryStatus() GetRecoveryStatus([]byte) []byte // recoveryManager.state isn't exported outside diff --git a/wallet/utxo.go b/wallet/utxo.go index 6ad0380d..4c4e6541 100644 --- a/wallet/utxo.go +++ b/wallet/utxo.go @@ -24,7 +24,7 @@ func (w *Wallet) GetAccountUtxos(accountID string, id string, unconfirmed, isSma accountUtxos = w.AccountMgr.ListUnconfirmedUtxo(accountID, isSmartContract) } - confirmedUTXOs, err := w.store.GetAccountUTXOs(string(prefix) + id) + confirmedUTXOs, err := w.store.ListAccountUTXOs(string(prefix) + id) if err != nil { log.WithFields(log.Fields{"module": logModule, "err": err}).Error("GetAccountUtxos fail.") }