OSDN Git Service

update ListTransactions
authorChengcheng Zhang <943420582@qq.com>
Mon, 1 Jul 2019 15:11:26 +0000 (23:11 +0800)
committerChengcheng Zhang <943420582@qq.com>
Mon, 1 Jul 2019 15:11:26 +0000 (23:11 +0800)
database/wallet_store.go
wallet/indexer.go
wallet/store.go

index 9cf899a..d6ecb88 100644 (file)
@@ -414,24 +414,7 @@ func (store *WalletStore) ListAccountUTXOs(key string) ([]*acc.UTXO, error) {
        return confirmedUTXOs, nil
 }
 
-// ListTransactions get all walletDB transactions
-func (store *WalletStore) ListTransactions() ([]*query.AnnotatedTx, error) {
-       annotatedTxs := []*query.AnnotatedTx{}
-
-       txIter := store.walletDB.IteratorPrefix([]byte(TxPrefix))
-       defer txIter.Release()
-       for txIter.Next() {
-               annotatedTx := &query.AnnotatedTx{}
-               if err := json.Unmarshal(txIter.Value(), &annotatedTx); err != nil {
-                       return nil, err
-               }
-               annotatedTxs = append(annotatedTxs, annotatedTx)
-       }
-
-       return annotatedTxs, nil
-}
-
-func (store *WalletStore) ListTransactionsssss(accountID string, StartTxID string, count uint, unconfirmed bool) ([]*query.AnnotatedTx, error) {
+func (store *WalletStore) ListTransactions(accountID string, StartTxID string, count uint, unconfirmed bool) ([]*query.AnnotatedTx, error) {
        annotatedTxs := []*query.AnnotatedTx{}
        var startKey []byte
        preFix := TxPrefix
@@ -460,18 +443,9 @@ func (store *WalletStore) ListTransactionsssss(accountID string, StartTxID strin
                if err := json.Unmarshal(itr.Value(), &annotatedTx); err != nil {
                        return nil, err
                }
-
-               // if accountID == "" || findTransactionsByAccount(annotatedTx, accountID) {
-               //      annotateTxsAsset(w, []*query.AnnotatedTx{annotatedTx})
-               //      annotatedTxs = append([]*query.AnnotatedTx{annotatedTx}, annotatedTxs...)
-               // }
                annotatedTxs = append(annotatedTxs, annotatedTx)
        }
 
-       // if unconfirmed {
-       //      sort.Sort(SortByTimestamp(annotatedTxs))
-       // }
-
        return annotatedTxs, nil
 }
 
index 431a690..b97c15f 100644 (file)
@@ -238,7 +238,7 @@ func findTransactionsByAccount(annotatedTx *query.AnnotatedTx, accountID string)
 // GetTransactions get all walletDB transactions or unconfirmed transactions, and filter transactions by accountID and StartTxID optional
 func (w *Wallet) GetTransactions(accountID string, StartTxID string, count uint, unconfirmed bool) ([]*query.AnnotatedTx, error) {
        annotatedTxs := []*query.AnnotatedTx{}
-       annotatedTxs, err := w.store.ListTransactionsssss(accountID, StartTxID, count, unconfirmed)
+       annotatedTxs, err := w.store.ListTransactions(accountID, StartTxID, count, unconfirmed)
        if err != nil {
                return nil, err
        }
index f25f0e9..eeec7c3 100644 (file)
@@ -28,8 +28,7 @@ type WalletStorer interface {
        GetRecoveryStatus([]byte) []byte // recoveryManager.state isn't exported outside
        GetWalletInfo() []byte           // need move database.NewWalletStore in wallet package
        ListAccountUTXOs(string) ([]*acc.UTXO, error)
-       ListTransactions() ([]*query.AnnotatedTx, error)
-       ListTransactionsssss(string, string, uint, bool) ([]*query.AnnotatedTx, error)
+       ListTransactions(string, string, uint, bool) ([]*query.AnnotatedTx, error)
        ListUnconfirmedTransactions() ([]*query.AnnotatedTx, error)
        SetAssetDefinition(*bc.AssetID, []byte)
        SetContractUTXO(bc.Hash, *acc.UTXO) error