diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-02-22 20:10:07 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-02-23 18:16:44 +0800 |
commit | d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851 (patch) | |
tree | 17c93170551d3eeabe2935de1765f157007f0dc2 /core/database_util.go | |
parent | 47af53f9aaf9aa7b12cd976eb150ccf3d64da6fd (diff) | |
download | go-tangerine-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.gz go-tangerine-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.zst go-tangerine-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.zip |
all: blidly swap out glog to our log15, logs need rework
Diffstat (limited to 'core/database_util.go')
-rw-r--r-- | core/database_util.go | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/core/database_util.go b/core/database_util.go index e83d5d5e7..23240b35e 100644 --- a/core/database_util.go +++ b/core/database_util.go @@ -28,8 +28,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethdb" - "github.com/ethereum/go-ethereum/logger" - "github.com/ethereum/go-ethereum/logger/glog" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" @@ -107,7 +106,7 @@ func GetBlockNumber(db ethdb.Database, hash common.Hash) uint64 { } header := new(types.Header) if err := rlp.Decode(bytes.NewReader(data), header); err != nil { - glog.Fatalf("failed to decode block header: %v", err) + log.Crit(fmt.Sprintf("failed to decode block header: %v", err)) } return header.Number.Uint64() } @@ -167,7 +166,7 @@ func GetHeader(db ethdb.Database, hash common.Hash, number uint64) *types.Header } header := new(types.Header) if err := rlp.Decode(bytes.NewReader(data), header); err != nil { - glog.V(logger.Error).Infof("invalid block header RLP for hash %x: %v", hash, err) + log.Error(fmt.Sprintf("invalid block header RLP for hash %x: %v", hash, err)) return nil } return header @@ -191,7 +190,7 @@ func GetBody(db ethdb.Database, hash common.Hash, number uint64) *types.Body { } body := new(types.Body) if err := rlp.Decode(bytes.NewReader(data), body); err != nil { - glog.V(logger.Error).Infof("invalid block body RLP for hash %x: %v", hash, err) + log.Error(fmt.Sprintf("invalid block body RLP for hash %x: %v", hash, err)) return nil } return body @@ -209,7 +208,7 @@ func GetTd(db ethdb.Database, hash common.Hash, number uint64) *big.Int { } td := new(big.Int) if err := rlp.Decode(bytes.NewReader(data), td); err != nil { - glog.V(logger.Error).Infof("invalid block total difficulty RLP for hash %x: %v", hash, err) + log.Error(fmt.Sprintf("invalid block total difficulty RLP for hash %x: %v", hash, err)) return nil } return td @@ -247,7 +246,7 @@ func GetBlockReceipts(db ethdb.Database, hash common.Hash, number uint64) types. } storageReceipts := []*types.ReceiptForStorage{} if err := rlp.DecodeBytes(data, &storageReceipts); err != nil { - glog.V(logger.Error).Infof("invalid receipt array RLP for hash %x: %v", hash, err) + log.Error(fmt.Sprintf("invalid receipt array RLP for hash %x: %v", hash, err)) return nil } receipts := make(types.Receipts, len(storageReceipts)) @@ -294,7 +293,7 @@ func GetReceipt(db ethdb.Database, txHash common.Hash) *types.Receipt { var receipt types.ReceiptForStorage err := rlp.DecodeBytes(data, &receipt) if err != nil { - glog.V(logger.Debug).Infoln("GetReceipt err:", err) + log.Debug(fmt.Sprint("GetReceipt err:", err)) } return (*types.Receipt)(&receipt) } @@ -303,7 +302,7 @@ func GetReceipt(db ethdb.Database, txHash common.Hash) *types.Receipt { func WriteCanonicalHash(db ethdb.Database, hash common.Hash, number uint64) error { key := append(append(headerPrefix, encodeBlockNumber(number)...), numSuffix...) if err := db.Put(key, hash.Bytes()); err != nil { - glog.Fatalf("failed to store number to hash mapping into database: %v", err) + log.Crit(fmt.Sprintf("failed to store number to hash mapping into database: %v", err)) } return nil } @@ -311,7 +310,7 @@ func WriteCanonicalHash(db ethdb.Database, hash common.Hash, number uint64) erro // WriteHeadHeaderHash stores the head header's hash. func WriteHeadHeaderHash(db ethdb.Database, hash common.Hash) error { if err := db.Put(headHeaderKey, hash.Bytes()); err != nil { - glog.Fatalf("failed to store last header's hash into database: %v", err) + log.Crit(fmt.Sprintf("failed to store last header's hash into database: %v", err)) } return nil } @@ -319,7 +318,7 @@ func WriteHeadHeaderHash(db ethdb.Database, hash common.Hash) error { // WriteHeadBlockHash stores the head block's hash. func WriteHeadBlockHash(db ethdb.Database, hash common.Hash) error { if err := db.Put(headBlockKey, hash.Bytes()); err != nil { - glog.Fatalf("failed to store last block's hash into database: %v", err) + log.Crit(fmt.Sprintf("failed to store last block's hash into database: %v", err)) } return nil } @@ -327,7 +326,7 @@ func WriteHeadBlockHash(db ethdb.Database, hash common.Hash) error { // WriteHeadFastBlockHash stores the fast head block's hash. func WriteHeadFastBlockHash(db ethdb.Database, hash common.Hash) error { if err := db.Put(headFastKey, hash.Bytes()); err != nil { - glog.Fatalf("failed to store last fast block's hash into database: %v", err) + log.Crit(fmt.Sprintf("failed to store last fast block's hash into database: %v", err)) } return nil } @@ -343,13 +342,13 @@ func WriteHeader(db ethdb.Database, header *types.Header) error { encNum := encodeBlockNumber(num) key := append(blockHashPrefix, hash...) if err := db.Put(key, encNum); err != nil { - glog.Fatalf("failed to store hash to number mapping into database: %v", err) + log.Crit(fmt.Sprintf("failed to store hash to number mapping into database: %v", err)) } key = append(append(headerPrefix, encNum...), hash...) if err := db.Put(key, data); err != nil { - glog.Fatalf("failed to store header into database: %v", err) + log.Crit(fmt.Sprintf("failed to store header into database: %v", err)) } - glog.V(logger.Debug).Infof("stored header #%v [%x…]", header.Number, hash[:4]) + log.Debug(fmt.Sprintf("stored header #%v [%x…]", header.Number, hash[:4])) return nil } @@ -366,9 +365,9 @@ func WriteBody(db ethdb.Database, hash common.Hash, number uint64, body *types.B func WriteBodyRLP(db ethdb.Database, hash common.Hash, number uint64, rlp rlp.RawValue) error { key := append(append(bodyPrefix, encodeBlockNumber(number)...), hash.Bytes()...) if err := db.Put(key, rlp); err != nil { - glog.Fatalf("failed to store block body into database: %v", err) + log.Crit(fmt.Sprintf("failed to store block body into database: %v", err)) } - glog.V(logger.Debug).Infof("stored block body [%x…]", hash.Bytes()[:4]) + log.Debug(fmt.Sprintf("stored block body [%x…]", hash.Bytes()[:4])) return nil } @@ -380,9 +379,9 @@ func WriteTd(db ethdb.Database, hash common.Hash, number uint64, td *big.Int) er } key := append(append(append(headerPrefix, encodeBlockNumber(number)...), hash.Bytes()...), tdSuffix...) if err := db.Put(key, data); err != nil { - glog.Fatalf("failed to store block total difficulty into database: %v", err) + log.Crit(fmt.Sprintf("failed to store block total difficulty into database: %v", err)) } - glog.V(logger.Debug).Infof("stored block total difficulty [%x…]: %v", hash.Bytes()[:4], td) + log.Debug(fmt.Sprintf("stored block total difficulty [%x…]: %v", hash.Bytes()[:4], td)) return nil } @@ -415,9 +414,9 @@ func WriteBlockReceipts(db ethdb.Database, hash common.Hash, number uint64, rece // Store the flattened receipt slice key := append(append(blockReceiptsPrefix, encodeBlockNumber(number)...), hash.Bytes()...) if err := db.Put(key, bytes); err != nil { - glog.Fatalf("failed to store block receipts into database: %v", err) + log.Crit(fmt.Sprintf("failed to store block receipts into database: %v", err)) } - glog.V(logger.Debug).Infof("stored block receipts [%x…]", hash.Bytes()[:4]) + log.Debug(fmt.Sprintf("stored block receipts [%x…]", hash.Bytes()[:4])) return nil } @@ -458,7 +457,7 @@ func WriteTransactions(db ethdb.Database, block *types.Block) error { } // Write the scheduled data into the database if err := batch.Write(); err != nil { - glog.Fatalf("failed to store transactions into database: %v", err) + log.Crit(fmt.Sprintf("failed to store transactions into database: %v", err)) } return nil } @@ -490,7 +489,7 @@ func WriteReceipts(db ethdb.Database, receipts types.Receipts) error { } // Write the scheduled data into the database if err := batch.Write(); err != nil { - glog.Fatalf("failed to store receipts into database: %v", err) + log.Crit(fmt.Sprintf("failed to store receipts into database: %v", err)) } return nil } @@ -552,7 +551,7 @@ func GetBlockByHashOld(db ethdb.Database, hash common.Hash) *types.Block { } var block types.StorageBlock if err := rlp.Decode(bytes.NewReader(data), &block); err != nil { - glog.V(logger.Error).Infof("invalid block RLP for hash %x: %v", hash, err) + log.Error(fmt.Sprintf("invalid block RLP for hash %x: %v", hash, err)) return nil } return (*types.Block)(&block) @@ -623,7 +622,7 @@ func WritePreimages(db ethdb.Database, number uint64, preimages map[common.Hash] if err := batch.Write(); err != nil { return fmt.Errorf("preimage write fail for block %d: %v", number, err) } - glog.V(logger.Debug).Infof("%d preimages in block %d, including %d new", len(preimages), number, hitCount) + log.Debug(fmt.Sprintf("%d preimages in block %d, including %d new", len(preimages), number, hitCount)) } return nil } |