OSDN Git Service

update listutxos
authorChengcheng Zhang <943420582@qq.com>
Sat, 29 Jun 2019 05:42:07 +0000 (13:42 +0800)
committerChengcheng Zhang <943420582@qq.com>
Sat, 29 Jun 2019 05:42:07 +0000 (13:42 +0800)
account/accounts.go
account/image.go
account/store.go
account/utxo_keeper.go
database/account_store.go
database/wallet_store.go
test/mock/UTXO.go
wallet/store.go
wallet/utxo.go

index f134d36..4dcd4b2 100644 (file)
@@ -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 {
index 62ce449..6ad7657 100644 (file)
@@ -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
        }
index 820f75a..7007284 100644 (file)
@@ -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
 }
index 57d5d68..db2abf1 100644 (file)
@@ -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)
        }
index f1f8bf0..8074fb5 100644 (file)
@@ -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()
 
index 4b6ac0c..9add00b 100644 (file)
@@ -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()
 
index b7e1e15..079c3d8 100644 (file)
@@ -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)
        }
index 3d7cce3..88ea808 100644 (file)
@@ -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
index 6ad0380..4c4e654 100644 (file)
@@ -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.")
        }