OSDN Git Service

improve the way to reverse transactions
authorYongfeng LI <wliyongfeng@gmail.com>
Sat, 7 Apr 2018 11:00:35 +0000 (19:00 +0800)
committerYongfeng LI <wliyongfeng@gmail.com>
Sat, 7 Apr 2018 11:00:35 +0000 (19:00 +0800)
wallet/indexer.go

index 3f723ed..8bd8a9f 100755 (executable)
@@ -443,12 +443,7 @@ func (w *Wallet) GetTransactionsByTxID(txID string) ([]*query.AnnotatedTx, error
                if err := json.Unmarshal(txIter.Value(), annotatedTx); err != nil {
                        return nil, err
                }
-               annotatedTxs = append(annotatedTxs, annotatedTx)
-       }
-
-       // reverse annotatedTxs
-       for i, j := 0, len(annotatedTxs) - 1; i < j; i, j = i + 1, j - 1 {
-               annotatedTxs[i], annotatedTxs[j] = annotatedTxs[j], annotatedTxs[i]
+               annotatedTxs = append([]*query.AnnotatedTx{annotatedTx}, annotatedTxs...)
        }
 
        return annotatedTxs, nil