From a5ed0d6e19d024041f2cce156ab1c1dd8087a104 Mon Sep 17 00:00:00 2001 From: Chengcheng Zhang <943420582@qq.com> Date: Mon, 24 Jun 2019 23:13:45 +0800 Subject: [PATCH] update --- database/wallet_store.go | 5 +++++ wallet/indexer.go | 8 ++++---- wallet/wallet.go | 6 +++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/database/wallet_store.go b/database/wallet_store.go index 4c2bde09..59da4948 100644 --- a/database/wallet_store.go +++ b/database/wallet_store.go @@ -146,8 +146,10 @@ func (store *WalletStore) GetAssetDefinition(assetID *bc.AssetID) []byte { // SetAssetDefinition set assetID and definition func (store *WalletStore) SetAssetDefinition(assetID *bc.AssetID, definition []byte) { if store.batch == nil { + fmt.Println("SetAssetDefinition... nil") store.DB.Set(asset.ExtAssetKey(assetID), definition) } else { + fmt.Println("SetAssetDefinition... not nil") store.batch.Set(asset.ExtAssetKey(assetID), definition) } } @@ -185,12 +187,15 @@ func (store *WalletStore) DeleteTransactions(height uint64) { // SetTransaction set raw transaction by block height and tx position func (store *WalletStore) SetTransaction(height uint64, position uint32, txID string, rawTx []byte) { + fmt.Println("SetTransaction...") if store.batch == nil { + fmt.Println("SetTransaction ... nil") batch := store.DB.NewBatch() batch.Set(calcAnnotatedKey(formatKey(height, position)), rawTx) batch.Set(calcTxIndexKey(txID), []byte(formatKey(height, position))) batch.Write() } else { + fmt.Println("SetTransaction ... not nil") store.batch.Set(calcAnnotatedKey(formatKey(height, position)), rawTx) store.batch.Set(calcTxIndexKey(txID), []byte(formatKey(height, position))) } diff --git a/wallet/indexer.go b/wallet/indexer.go index 7bc2b3cb..0d5f9f05 100644 --- a/wallet/indexer.go +++ b/wallet/indexer.go @@ -66,10 +66,10 @@ type TxSummary struct { } // indexTransactions saves all annotated transactions to the database. -func (w *Wallet) indexTransactions(b *types.Block, txStatus *bc.TransactionStatus) error { - annotatedTxs := w.filterAccountTxs(b, txStatus) - saveExternalAssetDefinition(b, w.store) - annotateTxsAccount(annotatedTxs, w.store) +func (w *Wallet) indexTransactions(b *types.Block, txStatus *bc.TransactionStatus, annotatedTxs []*query.AnnotatedTx) error { + // annotatedTxs := w.filterAccountTxs(b, txStatus) + // saveExternalAssetDefinition(b, w.store) + // annotateTxsAccount(annotatedTxs, w.store) for _, tx := range annotatedTxs { rawTx, err := json.Marshal(tx) diff --git a/wallet/wallet.go b/wallet/wallet.go index 7ffa8769..d3d97da8 100644 --- a/wallet/wallet.go +++ b/wallet/wallet.go @@ -187,10 +187,14 @@ func (w *Wallet) AttachBlock(block *types.Block) error { w.RecoveryMgr.finished() } + annotatedTxs := w.filterAccountTxs(block, txStatus) + saveExternalAssetDefinition(block, w.store) + annotateTxsAccount(annotatedTxs, w.store) + // w.store.InitBatch() // defer w.store.CommitBatch() - if err := w.indexTransactions(block, txStatus); err != nil { + if err := w.indexTransactions(block, txStatus, annotatedTxs); err != nil { return err } -- 2.11.0