aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2016-11-13 19:34:50 +0800
committerFelix Lange <fjl@twurst.com>2016-11-13 19:34:50 +0800
commit21701190ac0a838e347f31b7a918bb0a60c1e8c1 (patch)
treeec64fa5cac65f72ef4c0777c25620621c935ec4f
parent932d973e36ff0d41a6005b93d2d4ff1b4430fb04 (diff)
downloadgo-tangerine-21701190ac0a838e347f31b7a918bb0a60c1e8c1.tar
go-tangerine-21701190ac0a838e347f31b7a918bb0a60c1e8c1.tar.gz
go-tangerine-21701190ac0a838e347f31b7a918bb0a60c1e8c1.tar.bz2
go-tangerine-21701190ac0a838e347f31b7a918bb0a60c1e8c1.tar.lz
go-tangerine-21701190ac0a838e347f31b7a918bb0a60c1e8c1.tar.xz
go-tangerine-21701190ac0a838e347f31b7a918bb0a60c1e8c1.tar.zst
go-tangerine-21701190ac0a838e347f31b7a918bb0a60c1e8c1.zip
les: cleaned up logging (#3256)
-rw-r--r--les/handler.go42
-rw-r--r--les/server.go11
2 files changed, 29 insertions, 24 deletions
diff --git a/les/handler.go b/les/handler.go
index cf698d79c..8dca6b24c 100644
--- a/les/handler.go
+++ b/les/handler.go
@@ -248,7 +248,7 @@ func (pm *ProtocolManager) findServers() {
select {
case enode := <-enodes:
if !added[enode] {
- fmt.Println("Found LES server:", enode)
+ glog.V(logger.Info).Infoln("Found LES server:", enode)
added[enode] = true
if node, err := discover.ParseNode(enode); err == nil {
pm.p2pServer.AddPeer(node)
@@ -279,9 +279,9 @@ func (pm *ProtocolManager) Start(srvr *p2p.Server) {
} else {
if pm.topicDisc != nil {
go func() {
- fmt.Println("Starting topic register")
+ glog.V(logger.Debug).Infoln("Starting topic register")
pm.topicDisc.RegisterTopic(pm.lesTopic, pm.quitSync)
- fmt.Println("Stopped topic register")
+ glog.V(logger.Debug).Infoln("Stopped topic register")
}()
}
go func() {
@@ -381,7 +381,6 @@ func (pm *ProtocolManager) handle(p *peer) error {
select {
case announce := <-p.announceChn:
p.SendAnnounce(announce)
- //fmt.Println(" BROADCAST sent")
case <-stop:
return
}
@@ -392,7 +391,6 @@ func (pm *ProtocolManager) handle(p *peer) error {
for {
if err := pm.handleMsg(p); err != nil {
glog.V(logger.Debug).Infof("%v: message handling failed: %v", p, err)
- //fmt.Println("handleMsg err:", err)
return err
}
}
@@ -412,7 +410,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
var costs *requestCosts
var reqCnt, maxReqs int
- //fmt.Println("MSG", msg.Code, msg.Size)
+ glog.V(logger.Debug).Infoln("msg:", msg.Code, msg.Size)
if rc, ok := p.fcCosts[msg.Code]; ok { // check if msg is a supported request type
costs = rc
if p.fcClient == nil {
@@ -441,21 +439,23 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
// Handle the message depending on its contents
switch msg.Code {
case StatusMsg:
- glog.V(logger.Debug).Infof("LES: received StatusMsg from peer %v", p.id)
+ glog.V(logger.Debug).Infof("<=== StatusMsg from peer %v", p.id)
// Status messages should never arrive after the handshake
return errResp(ErrExtraStatusMsg, "uncontrolled status message")
// Block header query, collect the requested headers and reply
case AnnounceMsg:
+ glog.V(logger.Debug).Infoln("<=== AnnounceMsg from peer %v:", p.id)
+
var req announceData
if err := msg.Decode(&req); err != nil {
return errResp(ErrDecode, "%v: %v", msg, err)
}
- //fmt.Println("RECEIVED", req.Number, req.Hash, req.Td, req.ReorgDepth)
+ glog.V(logger.Detail).Infoln("AnnounceMsg:", req.Number, req.Hash, req.Td, req.ReorgDepth)
pm.fetcher.notify(p, &req)
case GetBlockHeadersMsg:
- glog.V(logger.Debug).Infof("LES: received GetBlockHeadersMsg from peer %v", p.id)
+ glog.V(logger.Debug).Infof("<=== GetBlockHeadersMsg from peer %v", p.id)
// Decode the complex header query
var req struct {
ReqID uint64
@@ -540,7 +540,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
return errResp(ErrUnexpectedResponse, "")
}
- glog.V(logger.Debug).Infof("LES: received BlockHeadersMsg from peer %v", p.id)
+ glog.V(logger.Debug).Infof("<=== BlockHeadersMsg from peer %v", p.id)
// A batch of headers arrived to one of our previous requests
var resp struct {
ReqID, BV uint64
@@ -560,7 +560,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
}
case GetBlockBodiesMsg:
- glog.V(logger.Debug).Infof("LES: received GetBlockBodiesMsg from peer %v", p.id)
+ glog.V(logger.Debug).Infof("<=== GetBlockBodiesMsg from peer %v", p.id)
// Decode the retrieval message
var req struct {
ReqID uint64
@@ -597,7 +597,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
return errResp(ErrUnexpectedResponse, "")
}
- glog.V(logger.Debug).Infof("LES: received BlockBodiesMsg from peer %v", p.id)
+ glog.V(logger.Debug).Infof("<=== BlockBodiesMsg from peer %v", p.id)
// A batch of block bodies arrived to one of our previous requests
var resp struct {
ReqID, BV uint64
@@ -614,7 +614,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
}
case GetCodeMsg:
- glog.V(logger.Debug).Infof("LES: received GetCodeMsg from peer %v", p.id)
+ glog.V(logger.Debug).Infof("<=== GetCodeMsg from peer %v", p.id)
// Decode the retrieval message
var req struct {
ReqID uint64
@@ -658,7 +658,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
return errResp(ErrUnexpectedResponse, "")
}
- glog.V(logger.Debug).Infof("LES: received CodeMsg from peer %v", p.id)
+ glog.V(logger.Debug).Infof("<=== CodeMsg from peer %v", p.id)
// A batch of node state data arrived to one of our previous requests
var resp struct {
ReqID, BV uint64
@@ -675,7 +675,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
}
case GetReceiptsMsg:
- glog.V(logger.Debug).Infof("LES: received GetReceiptsMsg from peer %v", p.id)
+ glog.V(logger.Debug).Infof("<=== GetReceiptsMsg from peer %v", p.id)
// Decode the retrieval message
var req struct {
ReqID uint64
@@ -721,7 +721,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
return errResp(ErrUnexpectedResponse, "")
}
- glog.V(logger.Debug).Infof("LES: received ReceiptsMsg from peer %v", p.id)
+ glog.V(logger.Debug).Infof("<=== ReceiptsMsg from peer %v", p.id)
// A batch of receipts arrived to one of our previous requests
var resp struct {
ReqID, BV uint64
@@ -738,7 +738,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
}
case GetProofsMsg:
- glog.V(logger.Debug).Infof("LES: received GetProofsMsg from peer %v", p.id)
+ glog.V(logger.Debug).Infof("<=== GetProofsMsg from peer %v", p.id)
// Decode the retrieval message
var req struct {
ReqID uint64
@@ -788,7 +788,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
return errResp(ErrUnexpectedResponse, "")
}
- glog.V(logger.Debug).Infof("LES: received ProofsMsg from peer %v", p.id)
+ glog.V(logger.Debug).Infof("<=== ProofsMsg from peer %v", p.id)
// A batch of merkle proofs arrived to one of our previous requests
var resp struct {
ReqID, BV uint64
@@ -805,7 +805,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
}
case GetHeaderProofsMsg:
- glog.V(logger.Debug).Infof("LES: received GetHeaderProofsMsg from peer %v", p.id)
+ glog.V(logger.Debug).Infof("<=== GetHeaderProofsMsg from peer %v", p.id)
// Decode the retrieval message
var req struct {
ReqID uint64
@@ -849,7 +849,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
return errResp(ErrUnexpectedResponse, "")
}
- glog.V(logger.Debug).Infof("LES: received HeaderProofsMsg from peer %v", p.id)
+ glog.V(logger.Debug).Infof("<=== HeaderProofsMsg from peer %v", p.id)
var resp struct {
ReqID, BV uint64
Data []ChtResp
@@ -882,7 +882,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
pm.server.fcCostStats.update(msg.Code, uint64(reqCnt), rcost)
default:
- glog.V(logger.Debug).Infof("LES: received unknown message with code %d from peer %v", msg.Code, p.id)
+ glog.V(logger.Debug).Infof("<=== unknown message with code %d from peer %v", msg.Code, p.id)
return errResp(ErrInvalidMsgCode, "%v", msg.Code)
}
diff --git a/les/server.go b/les/server.go
index daa28be05..60af6a9e1 100644
--- a/les/server.go
+++ b/les/server.go
@@ -19,7 +19,6 @@ package les
import (
"encoding/binary"
- "fmt"
"math"
"sync"
"time"
@@ -31,6 +30,8 @@ import (
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/les/flowcontrol"
"github.com/ethereum/go-ethereum/light"
+ "github.com/ethereum/go-ethereum/logger"
+ "github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
@@ -288,7 +289,9 @@ func (pm *ProtocolManager) blockLoop() {
}
lastHead = header
lastBroadcastTd = td
- //fmt.Println("BROADCAST", number, hash, td, reorg)
+
+ glog.V(logger.Debug).Infoln("===> ", number, hash, td, reorg)
+
announce := announceData{Hash: hash, Number: number, Td: td, ReorgDepth: reorg}
for _, p := range peers {
select {
@@ -391,7 +394,9 @@ func makeCht(db ethdb.Database) bool {
lastChtNum = 0
} else {
lastChtNum++
- fmt.Printf("CHT %d %064x\n", lastChtNum, root)
+
+ glog.V(logger.Info).Infoln("CHT %d %064x\n", lastChtNum, root)
+
storeChtRoot(db, lastChtNum, root)
var data [8]byte
binary.BigEndian.PutUint64(data[:], lastChtNum)