• R/O
  • HTTP
  • SSH
  • HTTPS

vapor: Commit

Golang implemented sidechain for Bytom


Commit MetaInfo

Revision2ab002adbbecb0ed4513a81d4d2f9a0fc9e01d43 (tree)
Time2019-07-11 17:20:52
Authormars <mars@byto...>
Commitermars

Log Message

fix bug

Change Summary

Incremental Difference

--- a/database/wallet_store.go
+++ b/database/wallet_store.go
@@ -345,6 +345,22 @@ func (store *WalletStore) ListAccountUTXOs(id string, isSmartContract bool) ([]*
345345 return confirmedUTXOs, nil
346346 }
347347
348+func findTransactionsByAccount(annotatedTx *query.AnnotatedTx, accountID string) bool {
349+ for _, input := range annotatedTx.Inputs {
350+ if input.AccountID == accountID {
351+ return true
352+ }
353+ }
354+
355+ for _, output := range annotatedTx.Outputs {
356+ if output.AccountID == accountID {
357+ return true
358+ }
359+ }
360+
361+ return false
362+}
363+
348364 func (store *WalletStore) ListTransactions(accountID string, StartTxID string, count uint, unconfirmed bool) ([]*query.AnnotatedTx, error) {
349365 annotatedTxs := []*query.AnnotatedTx{}
350366 var startKey []byte
@@ -376,8 +392,11 @@ func (store *WalletStore) ListTransactions(accountID string, StartTxID string, c
376392 return nil, err
377393 }
378394
379- annotatedTxs = append(annotatedTxs, annotatedTx)
380- txNum--
395+ if accountID == "" || findTransactionsByAccount(annotatedTx, accountID) {
396+ annotatedTxs = append(annotatedTxs, annotatedTx)
397+ txNum--
398+ }
399+
381400 }
382401
383402 return annotatedTxs, nil
--- a/wallet/indexer.go
+++ b/wallet/indexer.go
@@ -238,10 +238,8 @@ func (w *Wallet) GetTransactions(accountID string, StartTxID string, count uint,
238238
239239 newAnnotatedTxs := []*query.AnnotatedTx{}
240240 for _, annotatedTx := range annotatedTxs {
241- if accountID == "" || findTransactionsByAccount(annotatedTx, accountID) {
242- annotateTxsAsset(w, []*query.AnnotatedTx{annotatedTx})
243- newAnnotatedTxs = append([]*query.AnnotatedTx{annotatedTx}, newAnnotatedTxs...)
244- }
241+ annotateTxsAsset(w, []*query.AnnotatedTx{annotatedTx})
242+ newAnnotatedTxs = append([]*query.AnnotatedTx{annotatedTx}, newAnnotatedTxs...)
245243 }
246244
247245 if unconfirmed {
Show on old repository browser