Golang implemented sidechain for Bytom
Revision | 73f40d54126880235f710e714e26c859a8f492b1 (tree) |
---|---|
Zeit | 2019-07-11 17:26:30 |
Autor | Chengcheng Zhang <943420582@qq.c...> |
Commiter | Chengcheng Zhang |
update log
@@ -246,7 +246,7 @@ func (store *WalletStore) GetGlobalTransactionIndex(txID string) []byte { | ||
246 | 246 | func (store *WalletStore) GetStandardUTXO(outid bc.Hash) (*acc.UTXO, error) { |
247 | 247 | rawUTXO := store.db.Get(StandardUTXOKey(outid)) |
248 | 248 | if rawUTXO == nil { |
249 | - return nil, fmt.Errorf("failed get standard UTXO, outputID: %s ", outid.String()) | |
249 | + return nil, wallet.ErrGetStandardUTXO | |
250 | 250 | } |
251 | 251 | |
252 | 252 | UTXO := new(acc.UTXO) |
@@ -32,7 +32,7 @@ func annotateTxsAsset(w *Wallet, txs []*query.AnnotatedTx) { | ||
32 | 32 | |
33 | 33 | func (w *Wallet) getExternalDefinition(assetID *bc.AssetID) json.RawMessage { |
34 | 34 | externalAsset, err := w.Store.GetAsset(assetID) |
35 | - if err != nil { | |
35 | + if err != nil && err != ErrGetAsset { | |
36 | 36 | log.WithFields(log.Fields{"module": logModule, "err": err, "assetID": assetID.String()}).Info("fail on get asset definition.") |
37 | 37 | } |
38 | 38 | if externalAsset == nil { |
@@ -106,22 +106,22 @@ transactionLoop: | ||
106 | 106 | if _, err := w.AccountMgr.GetControlProgram(bc.NewHash(hash)); err == nil { |
107 | 107 | annotatedTxs = append(annotatedTxs, w.buildAnnotatedTransaction(tx, b, statusFail, pos)) |
108 | 108 | continue transactionLoop |
109 | - } else { | |
110 | - log.WithFields(log.Fields{"module": logModule, "err": err, "hash": hex.EncodeToString(hash[:])}).Info("filterAccountTxs fail.") | |
109 | + } else if err != account.ErrFindCtrlProgram { | |
110 | + log.WithFields(log.Fields{"module": logModule, "err": err, "hash": hex.EncodeToString(hash[:])}).Error("filterAccountTxs fail.") | |
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
114 | 114 | for _, v := range tx.Inputs { |
115 | 115 | outid, err := v.SpentOutputID() |
116 | 116 | if err != nil { |
117 | - log.WithFields(log.Fields{"module": logModule, "err": err, "outputID": hex.EncodeToString(outid.Bytes())}).Info("filterAccountTxs fail.") | |
117 | + log.WithFields(log.Fields{"module": logModule, "err": err, "outputID": hex.EncodeToString(outid.Bytes())}).Error("filterAccountTxs fail.") | |
118 | 118 | continue |
119 | 119 | } |
120 | 120 | if _, err = w.Store.GetStandardUTXO(outid); err == nil { |
121 | 121 | annotatedTxs = append(annotatedTxs, w.buildAnnotatedTransaction(tx, b, statusFail, pos)) |
122 | 122 | continue transactionLoop |
123 | - } else { | |
124 | - log.WithFields(log.Fields{"module": logModule, "err": err, "outputID": hex.EncodeToString(outid.Bytes())}).Info("filterAccountTxs fail.") | |
123 | + } else if err != ErrGetStandardUTXO { | |
124 | + log.WithFields(log.Fields{"module": logModule, "err": err, "outputID": hex.EncodeToString(outid.Bytes())}).Error("filterAccountTxs fail.") | |
125 | 125 | } |
126 | 126 | } |
127 | 127 | } |
@@ -1,6 +1,7 @@ | ||
1 | 1 | package wallet |
2 | 2 | |
3 | 3 | import ( |
4 | + "encoding/hex" | |
4 | 5 | "fmt" |
5 | 6 | "sort" |
6 | 7 | "time" |
@@ -9,6 +10,7 @@ import ( | ||
9 | 10 | |
10 | 11 | log "github.com/sirupsen/logrus" |
11 | 12 | |
13 | + acc "github.com/vapor/account" | |
12 | 14 | "github.com/vapor/blockchain/query" |
13 | 15 | "github.com/vapor/crypto/sha3pool" |
14 | 16 | "github.com/vapor/protocol" |
@@ -113,8 +115,8 @@ func (w *Wallet) checkRelatedTransaction(tx *types.Tx) bool { | ||
113 | 115 | var hash [32]byte |
114 | 116 | sha3pool.Sum256(hash[:], v.ControlProgram()) |
115 | 117 | cp, err := w.AccountMgr.GetControlProgram(bc.NewHash(hash)) |
116 | - if err != nil { | |
117 | - log.WithFields(log.Fields{"module": logModule, "err": err, "hash": string(hash[:])}).Error("checkRelatedTransaction fail.") | |
118 | + if err != nil && err != acc.ErrFindCtrlProgram { | |
119 | + log.WithFields(log.Fields{"module": logModule, "err": err, "hash": hex.EncodeToString(hash[:])}).Error("checkRelatedTransaction fail.") | |
118 | 120 | continue |
119 | 121 | } |
120 | 122 | if cp != nil { |
@@ -128,7 +130,7 @@ func (w *Wallet) checkRelatedTransaction(tx *types.Tx) bool { | ||
128 | 130 | continue |
129 | 131 | } |
130 | 132 | utxo, err := w.Store.GetStandardUTXO(outid) |
131 | - if err != nil { | |
133 | + if err != nil && err != ErrGetStandardUTXO { | |
132 | 134 | log.WithFields(log.Fields{"module": logModule, "err": err, "outputID": outid.String()}).Error("checkRelatedTransaction fail.") |
133 | 135 | continue |
134 | 136 | } |
@@ -121,7 +121,7 @@ func (w *Wallet) filterAccountUtxo(utxos []*account.UTXO) []*account.UTXO { | ||
121 | 121 | var hash [32]byte |
122 | 122 | sha3pool.Sum256(hash[:], []byte(s)) |
123 | 123 | cp, err := w.AccountMgr.GetControlProgram(bc.NewHash(hash)) |
124 | - if err != nil { | |
124 | + if err != nil && err != account.ErrFindCtrlProgram { | |
125 | 125 | log.WithFields(log.Fields{"module": logModule, "err": err}).Error("filterAccountUtxo fail.") |
126 | 126 | continue |
127 | 127 | } |
@@ -29,6 +29,7 @@ var ( | ||
29 | 29 | ErrGetWalletStatusInfo = errors.New("failed get wallet info") |
30 | 30 | ErrGetAsset = errors.New("Failed to find asset definition") |
31 | 31 | ErrAccntTxIDNotFound = errors.New("account TXID not found") |
32 | + ErrGetStandardUTXO = errors.New("failed get standard UTXO") | |
32 | 33 | ) |
33 | 34 | |
34 | 35 | //StatusInfo is base valid block info to handle orphan block rollback |