OSDN Git Service

update
[bytom/vapor.git] / account / utxo_keeper.go
index fc27b7e..57d5d68 100644 (file)
@@ -3,14 +3,11 @@ package account
 import (
        "bytes"
        "container/list"
-       "encoding/json"
        "sort"
        "sync"
        "sync/atomic"
        "time"
 
-       log "github.com/sirupsen/logrus"
-
        "github.com/vapor/errors"
        "github.com/vapor/protocol/bc"
 )
@@ -222,14 +219,9 @@ func (uk *utxoKeeper) findUtxos(accountID string, assetID *bc.AssetID, useUnconf
                }
        }
 
-       rawUTXOs := uk.store.GetUTXOs()
-       for _, rawUTXO := range rawUTXOs {
-               utxo := new(UTXO)
-               if err := json.Unmarshal(rawUTXO, utxo); err != nil {
-                       log.WithFields(log.Fields{"module": logModule, "err": err}).Error("utxoKeeper findUtxos fail on unmarshal utxo")
-                       continue
-               }
-               appendUtxo(utxo)
+       UTXOs := uk.store.GetUTXOs()
+       for _, UTXO := range UTXOs {
+               appendUtxo(UTXO)
        }
 
        if !useUnconfirmed {
@@ -246,15 +238,7 @@ func (uk *utxoKeeper) findUtxo(outHash bc.Hash, useUnconfirmed bool) (*UTXO, err
        if u, ok := uk.unconfirmed[outHash]; useUnconfirmed && ok {
                return u, nil
        }
-
-       u := &UTXO{}
-       if data := uk.store.GetStandardUTXO(outHash); data != nil {
-               return u, json.Unmarshal(data, u)
-       }
-       if data := uk.store.GetContractUTXO(outHash); data != nil {
-               return u, json.Unmarshal(data, u)
-       }
-       return nil, ErrMatchUTXO
+       return uk.store.GetUTXO(outHash)
 }
 
 func (uk *utxoKeeper) optUTXOs(utxos []*UTXO, amount uint64) ([]*UTXO, uint64, uint64) {