OSDN Git Service

writer close
[bytom/vapor.git] / wallet / indexer.go
index 317ee0e..f107aec 100644 (file)
@@ -34,6 +34,9 @@ func saveExternalAssetDefinition(b *types.Block, store WalletStore) error {
        for _, tx := range b.Transactions {
                for _, orig := range tx.Inputs {
                        if cci, ok := orig.TypedInput.(*types.CrossChainInput); ok {
+                               if cci.AssetId.String() == consensus.BTMAssetID.String() {
+                                       continue
+                               }
                                assetID := cci.AssetId
                                if _, err := newStore.GetAsset(assetID); err == nil {
                                        continue
@@ -106,22 +109,22 @@ transactionLoop:
                        if _, err := w.AccountMgr.GetControlProgram(bc.NewHash(hash)); err == nil {
                                annotatedTxs = append(annotatedTxs, w.buildAnnotatedTransaction(tx, b, statusFail, pos))
                                continue transactionLoop
-                       } else {
-                               log.WithFields(log.Fields{"module": logModule, "err": err, "hash": hex.EncodeToString(hash[:])}).Info("filterAccountTxs fail.")
+                       } else if err != account.ErrFindCtrlProgram {
+                               log.WithFields(log.Fields{"module": logModule, "err": err, "hash": hex.EncodeToString(hash[:])}).Error("filterAccountTxs fail.")
                        }
                }
 
                for _, v := range tx.Inputs {
                        outid, err := v.SpentOutputID()
                        if err != nil {
-                               log.WithFields(log.Fields{"module": logModule, "err": err, "outputID": hex.EncodeToString(outid.Bytes())}).Info("filterAccountTxs fail.")
+                               log.WithFields(log.Fields{"module": logModule, "err": err, "outputID": outid.String()}).Error("filterAccountTxs fail.")
                                continue
                        }
                        if _, err = w.Store.GetStandardUTXO(outid); err == nil {
                                annotatedTxs = append(annotatedTxs, w.buildAnnotatedTransaction(tx, b, statusFail, pos))
                                continue transactionLoop
-                       } else {
-                               log.WithFields(log.Fields{"module": logModule, "err": err, "outputID": hex.EncodeToString(outid.Bytes())}).Info("filterAccountTxs fail.")
+                       } else if err != ErrGetStandardUTXO {
+                               log.WithFields(log.Fields{"module": logModule, "err": err, "outputID": outid.String()}).Error("filterAccountTxs fail.")
                        }
                }
        }
@@ -212,7 +215,7 @@ func (w *Wallet) GetTransactionsSummary(transactions []*query.AnnotatedTx) []TxS
        return Txs
 }
 
-func findTransactionsByAccount(annotatedTx *query.AnnotatedTx, accountID string) bool {
+func FindTransactionsByAccount(annotatedTx *query.AnnotatedTx, accountID string) bool {
        for _, input := range annotatedTx.Inputs {
                if input.AccountID == accountID {
                        return true
@@ -238,16 +241,14 @@ func (w *Wallet) GetTransactions(accountID string, StartTxID string, count uint,
 
        newAnnotatedTxs := []*query.AnnotatedTx{}
        for _, annotatedTx := range annotatedTxs {
-               if accountID == "" || findTransactionsByAccount(annotatedTx, accountID) {
-                       annotateTxsAsset(w, []*query.AnnotatedTx{annotatedTx})
-                       newAnnotatedTxs = append([]*query.AnnotatedTx{annotatedTx}, newAnnotatedTxs...)
-               }
+               annotateTxsAsset(w, []*query.AnnotatedTx{annotatedTx})
+               newAnnotatedTxs = append([]*query.AnnotatedTx{annotatedTx}, newAnnotatedTxs...)
        }
 
        if unconfirmed {
-               sort.Sort(SortByTimestamp(annotatedTxs))
+               sort.Sort(SortByTimestamp(newAnnotatedTxs))
        } else {
-               sort.Sort(SortByHeight(annotatedTxs))
+               sort.Sort(SortByHeight(newAnnotatedTxs))
        }
 
        return newAnnotatedTxs, nil