OSDN Git Service

update
authorChengcheng Zhang <943420582@qq.com>
Mon, 8 Jul 2019 17:17:49 +0000 (01:17 +0800)
committerChengcheng Zhang <943420582@qq.com>
Mon, 8 Jul 2019 17:17:49 +0000 (01:17 +0800)
database/account_store.go
database/wallet_store.go
test/wallet_test.go

index dcbc470..a02f17a 100644 (file)
@@ -2,7 +2,6 @@ package database
 
 import (
        "encoding/json"
-       "fmt"
        "sort"
        "strings"
 
@@ -56,7 +55,6 @@ func Bip44ContractIndexKey(accountID string, change bool) []byte {
 
 // ContractKey account control promgram store prefix
 func ContractKey(hash bc.Hash) []byte {
-       fmt.Println("ContractKey...")
        return append(ContractPrefix, hash.Bytes()...)
 }
 
index a904548..dcb664f 100644 (file)
@@ -153,9 +153,9 @@ func (store *WalletStore) DeleteTransactions(height uint64) {
        txIter := store.db.IteratorPrefix(calcDeleteKey(height))
        defer txIter.Release()
 
-       tmpTx := query.AnnotatedTx{}
        for txIter.Next() {
-               if err := json.Unmarshal(txIter.Value(), &tmpTx); err == nil {
+               tmpTx := new(query.AnnotatedTx)
+               if err := json.Unmarshal(txIter.Value(), tmpTx); err == nil {
                        batch.Delete(calcTxIndexKey(tmpTx.ID.String()))
                } else {
                        log.WithFields(log.Fields{"module": logModule, "err": err}).Warning("fail on DeleteTransactions.")
@@ -382,7 +382,7 @@ func (store *WalletStore) ListTransactions(accountID string, StartTxID string, c
 
        for txNum := count; itr.Next() && txNum > 0; {
                annotatedTx := new(query.AnnotatedTx)
-               if err := json.Unmarshal(itr.Value(), &annotatedTx); err != nil {
+               if err := json.Unmarshal(itr.Value(), annotatedTx); err != nil {
                        return nil, err
                }
 
@@ -400,8 +400,8 @@ func (store *WalletStore) ListUnconfirmedTransactions() ([]*query.AnnotatedTx, e
        defer txIter.Release()
 
        for txIter.Next() {
-               annotatedTx := &query.AnnotatedTx{}
-               if err := json.Unmarshal(txIter.Value(), &annotatedTx); err != nil {
+               annotatedTx := new(query.AnnotatedTx)
+               if err := json.Unmarshal(txIter.Value(), annotatedTx); err != nil {
                        return nil, err
                }
 
index 8da4c17..717ec2c 100644 (file)
@@ -162,17 +162,22 @@ func TestWalletUpdate(t *testing.T) {
 
 //             accountStore := database.NewAccountStore(testDB)
 //             accountManager := account.NewManager(accountStore, chain)
-//             w := newMockWallet(walletStore, accountManager, nil, chain, dispatcher, false)
-//             // w := newMockWallet(walletStore, nil, nil, chain, dispatcher, false)
-//             w.Wallet.Status = *walletInfo
+//             // w := newMockWallet(walletStore, accountManager, nil, chain, dispatcher, false)
+//             w, err := wt.NewWallet(walletStore, accountManager, nil, nil, chain, dispatcher, false)
+//             if err != nil {
+//                     t.Fatal(err)
+//             }
+//             var hash [32]byte
+//             w.Status.WorkHash = bc.NewHash(hash)
+//             w.Status = *walletInfo
 
 //             // rescan wallet.
-//             if err := w.Wallet.LoadWalletInfo(); err != nil {
+//             if err := w.LoadWalletInfo(); err != nil {
 //                     t.Fatal(err)
 //             }
 
 //             block := config.GenesisBlock()
-//             if w.Wallet.Status.WorkHash != block.Hash() {
+//             if w.Status.WorkHash != block.Hash() {
 //                     t.Fatal("reattach from genesis block")
 //             }
 //     }