OSDN Git Service

update
authorChengcheng Zhang <943420582@qq.com>
Sat, 22 Jun 2019 07:24:36 +0000 (15:24 +0800)
committerChengcheng Zhang <943420582@qq.com>
Sat, 22 Jun 2019 07:24:36 +0000 (15:24 +0800)
wallet/indexer.go
wallet/store.go

index fa9ceb0..e399517 100644 (file)
@@ -113,8 +113,7 @@ func (w *Wallet) indexTransactions(b *types.Block, txStatus *bc.TransactionStatu
                        return err
                }
 
-               w.store.SetRawTransaction(b.Height, tx.Position, rawTx)
-               w.store.SetHeightAndPostion(tx.ID.String(), b.Height, tx.Position)
+               w.store.SetTransaction(b.Height, tx.Position, tx.ID.String(), rawTx)
                w.store.DeleteUnconfirmedTransaction(tx.ID.String())
        }
 
index c8c658f..6638d04 100644 (file)
@@ -19,8 +19,7 @@ type Store interface {
        GetRawProgramByHash(common.Hash) []byte
        GetAccount(string) []byte
        DeleteTransaction(uint64)
-       SetRawTransaction(uint64, uint32, []byte)
-       SetHeightAndPostion(string, uint64, uint32)
+       SetTransaction(uint64, uint32, string, []byte)
        DeleteUnconfirmedTransaction(string)
        SetGlobalTransactionIndex(string, *bc.Hash, uint64)
        GetStandardUTXO(bc.Hash) []byte
@@ -95,16 +94,10 @@ func (store *LevelDBStore) DeleteTransaction(height uint64) {
        batch.Write()
 }
 
-// SetRawTransaction set raw transaction by block height and tx position
-func (store *LevelDBStore) SetRawTransaction(height uint64, position uint32, rawTx []byte) {
+// SetTransaction set raw transaction by block height and tx position
+func (store *LevelDBStore) SetTransaction(height uint64, position uint32, txID string, rawTx []byte) {
        batch := store.DB.NewBatch()
        batch.Set(calcAnnotatedKey(formatKey(height, position)), rawTx)
-       batch.Write()
-}
-
-// SetHeightAndPostion set block height and tx position according to tx ID
-func (store *LevelDBStore) SetHeightAndPostion(txID string, height uint64, position uint32) {
-       batch := store.DB.NewBatch()
        batch.Set(calcTxIndexKey(txID), []byte(formatKey(height, position)))
        batch.Write()
 }