aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/network/protocol.go
diff options
context:
space:
mode:
Diffstat (limited to 'swarm/network/protocol.go')
-rw-r--r--swarm/network/protocol.go43
1 files changed, 21 insertions, 22 deletions
diff --git a/swarm/network/protocol.go b/swarm/network/protocol.go
index 763fb0b8e..44787947c 100644
--- a/swarm/network/protocol.go
+++ b/swarm/network/protocol.go
@@ -38,8 +38,7 @@ import (
"github.com/ethereum/go-ethereum/contracts/chequebook"
"github.com/ethereum/go-ethereum/errs"
- "github.com/ethereum/go-ethereum/logger"
- "github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/discover"
bzzswap "github.com/ethereum/go-ethereum/swarm/services/swap"
@@ -201,7 +200,7 @@ func run(requestDb *storage.LDBDatabase, depo StorageHandler, backend chequebook
// the main forever loop that handles incoming requests
for {
if self.hive.blockRead {
- glog.V(logger.Warn).Infof("Cannot read network")
+ log.Warn(fmt.Sprintf("Cannot read network"))
time.Sleep(100 * time.Millisecond)
continue
}
@@ -221,7 +220,7 @@ func (self *bzz) Drop() {
// one cycle of the main forever loop that handles and dispatches incoming messages
func (self *bzz) handle() error {
msg, err := self.rw.ReadMsg()
- glog.V(logger.Debug).Infof("<- %v", msg)
+ log.Debug(fmt.Sprintf("<- %v", msg))
if err != nil {
return err
}
@@ -236,7 +235,7 @@ func (self *bzz) handle() error {
case statusMsg:
// no extra status message allowed. The one needed already handled by
// handleStatus
- glog.V(logger.Debug).Infof("Status message: %v", msg)
+ log.Debug(fmt.Sprintf("Status message: %v", msg))
return self.protoError(ErrExtraStatusMsg, "")
case storeRequestMsg:
@@ -250,7 +249,7 @@ func (self *bzz) handle() error {
}
// last Active time is set only when receiving chunks
self.lastActive = time.Now()
- glog.V(logger.Detail).Infof("incoming store request: %s", req.String())
+ log.Trace(fmt.Sprintf("incoming store request: %s", req.String()))
// swap accounting is done within forwarding
self.storage.HandleStoreRequestMsg(&req, &peer{bzz: self})
@@ -263,7 +262,7 @@ func (self *bzz) handle() error {
req.from = &peer{bzz: self}
// if request is lookup and not to be delivered
if req.isLookup() {
- glog.V(logger.Detail).Infof("self lookup for %v: responding with peers only...", req.from)
+ log.Trace(fmt.Sprintf("self lookup for %v: responding with peers only...", req.from))
} else if req.Key == nil {
return self.protoError(ErrDecode, "protocol handler: req.Key == nil || req.Timeout == nil")
} else {
@@ -281,7 +280,7 @@ func (self *bzz) handle() error {
return self.protoError(ErrDecode, "<- %v: %v", msg, err)
}
req.from = &peer{bzz: self}
- glog.V(logger.Detail).Infof("<- peer addresses: %v", req)
+ log.Trace(fmt.Sprintf("<- peer addresses: %v", req))
self.hive.HandlePeersMsg(&req, &peer{bzz: self})
case syncRequestMsg:
@@ -289,7 +288,7 @@ func (self *bzz) handle() error {
if err := msg.Decode(&req); err != nil {
return self.protoError(ErrDecode, "<- %v: %v", msg, err)
}
- glog.V(logger.Debug).Infof("<- sync request: %v", req)
+ log.Debug(fmt.Sprintf("<- sync request: %v", req))
self.lastActive = time.Now()
self.sync(req.SyncState)
@@ -299,7 +298,7 @@ func (self *bzz) handle() error {
if err := msg.Decode(&req); err != nil {
return self.protoError(ErrDecode, "<- %v: %v", msg, err)
}
- glog.V(logger.Debug).Infof("<- unsynced keys : %s", req.String())
+ log.Debug(fmt.Sprintf("<- unsynced keys : %s", req.String()))
err := self.storage.HandleUnsyncedKeysMsg(&req, &peer{bzz: self})
self.lastActive = time.Now()
if err != nil {
@@ -313,7 +312,7 @@ func (self *bzz) handle() error {
if err := msg.Decode(&req); err != nil {
return self.protoError(ErrDecode, "<-msg %v: %v", msg, err)
}
- glog.V(logger.Debug).Infof("<- delivery request: %s", req.String())
+ log.Debug(fmt.Sprintf("<- delivery request: %s", req.String()))
err := self.storage.HandleDeliveryRequestMsg(&req, &peer{bzz: self})
self.lastActive = time.Now()
if err != nil {
@@ -327,7 +326,7 @@ func (self *bzz) handle() error {
if err := msg.Decode(&req); err != nil {
return self.protoError(ErrDecode, "<- %v: %v", msg, err)
}
- glog.V(logger.Debug).Infof("<- payment: %s", req.String())
+ log.Debug(fmt.Sprintf("<- payment: %s", req.String()))
self.swap.Receive(int(req.Units), req.Promise)
}
@@ -385,7 +384,7 @@ func (self *bzz) handleStatus() (err error) {
}
self.remoteAddr = self.peerAddr(status.Addr)
- glog.V(logger.Detail).Infof("self: advertised IP: %v, peer advertised: %v, local address: %v\npeer: advertised IP: %v, remote address: %v\n", self.selfAddr(), self.remoteAddr, self.peer.LocalAddr(), status.Addr.IP, self.peer.RemoteAddr())
+ log.Trace(fmt.Sprintf("self: advertised IP: %v, peer advertised: %v, local address: %v\npeer: advertised IP: %v, remote address: %v\n", self.selfAddr(), self.remoteAddr, self.peer.LocalAddr(), status.Addr.IP, self.peer.RemoteAddr()))
if self.swapEnabled {
// set remote profile for accounting
@@ -395,14 +394,14 @@ func (self *bzz) handleStatus() (err error) {
}
}
- glog.V(logger.Info).Infof("Peer %08x is capable (%d/%d)", self.remoteAddr.Addr[:4], status.Version, status.NetworkId)
+ log.Info(fmt.Sprintf("Peer %08x is capable (%d/%d)", self.remoteAddr.Addr[:4], status.Version, status.NetworkId))
err = self.hive.addPeer(&peer{bzz: self})
if err != nil {
return self.protoError(ErrUnwanted, "%v", err)
}
// hive sets syncstate so sync should start after node added
- glog.V(logger.Info).Infof("syncronisation request sent with %v", self.syncState)
+ log.Info(fmt.Sprintf("syncronisation request sent with %v", self.syncState))
self.syncRequest()
return nil
@@ -421,7 +420,7 @@ func (self *bzz) sync(state *syncState) error {
// an explicitly received nil syncstate disables syncronisation
if state == nil {
self.syncEnabled = false
- glog.V(logger.Warn).Infof("syncronisation disabled for peer %v", self)
+ log.Warn(fmt.Sprintf("syncronisation disabled for peer %v", self))
state = &syncState{DbSyncState: &storage.DbSyncState{}, Synced: true}
} else {
state.synced = make(chan bool)
@@ -430,7 +429,7 @@ func (self *bzz) sync(state *syncState) error {
state.Start = storage.Key(start[:])
state.Stop = storage.Key(stop[:])
}
- glog.V(logger.Debug).Infof("syncronisation requested by peer %v at state %v", self, state)
+ log.Debug(fmt.Sprintf("syncronisation requested by peer %v at state %v", self, state))
}
var err error
self.syncer, err = newSyncer(
@@ -443,7 +442,7 @@ func (self *bzz) sync(state *syncState) error {
if err != nil {
return self.protoError(ErrSync, "%v", err)
}
- glog.V(logger.Detail).Infof("syncer set for peer %v", self)
+ log.Trace(fmt.Sprintf("syncer set for peer %v", self))
return nil
}
@@ -490,11 +489,11 @@ func (self *bzz) store(req *storeRequestMsgData) error {
func (self *bzz) syncRequest() error {
req := &syncRequestMsgData{}
if self.hive.syncEnabled {
- glog.V(logger.Debug).Infof("syncronisation request to peer %v at state %v", self, self.syncState)
+ log.Debug(fmt.Sprintf("syncronisation request to peer %v at state %v", self, self.syncState))
req.SyncState = self.syncState
}
if self.syncState == nil {
- glog.V(logger.Warn).Infof("syncronisation disabled for peer %v at state %v", self, self.syncState)
+ log.Warn(fmt.Sprintf("syncronisation disabled for peer %v at state %v", self, self.syncState))
}
return self.send(syncRequestMsg, req)
}
@@ -534,7 +533,7 @@ func (self *bzz) peers(req *peersMsgData) error {
func (self *bzz) protoError(code int, format string, params ...interface{}) (err *errs.Error) {
err = self.errors.New(code, format, params...)
- err.Log(glog.V(logger.Info))
+ log.Info(err.Error())
return
}
@@ -542,7 +541,7 @@ func (self *bzz) send(msg uint64, data interface{}) error {
if self.hive.blockWrite {
return fmt.Errorf("network write blocked")
}
- glog.V(logger.Detail).Infof("-> %v: %v (%T) to %v", msg, data, data, self)
+ log.Trace(fmt.Sprintf("-> %v: %v (%T) to %v", msg, data, data, self))
err := p2p.Send(self.rw, msg, data)
if err != nil {
self.Drop()