// 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)
}
}
// 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)))
}
}
// 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)
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
}