OSDN Git Service

add asset info when query transactions (#685)
authorYongfeng LI <wliyongfeng@gmail.com>
Wed, 18 Apr 2018 01:45:39 +0000 (09:45 +0800)
committerGitHub <noreply@github.com>
Wed, 18 Apr 2018 01:45:39 +0000 (09:45 +0800)
* add asset info when query transactions

* correct array definition

wallet/indexer.go

index 2d5fd79..9552117 100644 (file)
@@ -188,7 +188,6 @@ type TxSummary struct {
 func (w *Wallet) indexTransactions(batch db.Batch, b *types.Block, txStatus *bc.TransactionStatus) error {
        annotatedTxs := w.filterAccountTxs(b, txStatus)
        saveExternalAssetDefinition(b, w.DB)
-       annotateTxsAsset(w, annotatedTxs)
        annotateTxsAccount(annotatedTxs, w.DB)
 
        for _, tx := range annotatedTxs {
@@ -443,6 +442,7 @@ func (w *Wallet) GetTransactionsByTxID(txID string) ([]*query.AnnotatedTx, error
                if err := json.Unmarshal(txIter.Value(), annotatedTx); err != nil {
                        return nil, err
                }
+               annotateTxsAsset(w, []*query.AnnotatedTx{annotatedTx})
                annotatedTxs = append([]*query.AnnotatedTx{annotatedTx}, annotatedTxs...)
        }
 
@@ -514,6 +514,7 @@ func (w *Wallet) GetTransactionsByAccountID(accountID string) ([]*query.Annotate
                }
 
                if findTransactionsByAccount(annotatedTx, accountID) {
+                       annotateTxsAsset(w, []*query.AnnotatedTx{annotatedTx})
                        annotatedTxs = append(annotatedTxs, annotatedTx)
                }
        }