|
|
@ -133,7 +133,7 @@ type retrieveRequestMsgData struct { |
|
|
|
from *peer //
|
|
|
|
from *peer //
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (self retrieveRequestMsgData) String() string { |
|
|
|
func (self *retrieveRequestMsgData) String() string { |
|
|
|
var from string |
|
|
|
var from string |
|
|
|
if self.from == nil { |
|
|
|
if self.from == nil { |
|
|
|
from = "ourselves" |
|
|
|
from = "ourselves" |
|
|
@ -148,12 +148,12 @@ func (self retrieveRequestMsgData) String() string { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// lookups are encoded by missing request ID
|
|
|
|
// lookups are encoded by missing request ID
|
|
|
|
func (self retrieveRequestMsgData) isLookup() bool { |
|
|
|
func (self *retrieveRequestMsgData) isLookup() bool { |
|
|
|
return self.Id == 0 |
|
|
|
return self.Id == 0 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// sets timeout fields
|
|
|
|
// sets timeout fields
|
|
|
|
func (self retrieveRequestMsgData) setTimeout(t *time.Time) { |
|
|
|
func (self *retrieveRequestMsgData) setTimeout(t *time.Time) { |
|
|
|
self.timeout = t |
|
|
|
self.timeout = t |
|
|
|
if t != nil { |
|
|
|
if t != nil { |
|
|
|
self.Timeout = uint64(t.UnixNano()) |
|
|
|
self.Timeout = uint64(t.UnixNano()) |
|
|
@ -162,7 +162,7 @@ func (self retrieveRequestMsgData) setTimeout(t *time.Time) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (self retrieveRequestMsgData) getTimeout() (t *time.Time) { |
|
|
|
func (self *retrieveRequestMsgData) getTimeout() (t *time.Time) { |
|
|
|
if self.Timeout > 0 && self.timeout == nil { |
|
|
|
if self.Timeout > 0 && self.timeout == nil { |
|
|
|
timeout := time.Unix(int64(self.Timeout), 0) |
|
|
|
timeout := time.Unix(int64(self.Timeout), 0) |
|
|
|
t = &timeout |
|
|
|
t = &timeout |
|
|
@ -180,7 +180,7 @@ type peerAddr struct { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// peerAddr pretty prints as enode
|
|
|
|
// peerAddr pretty prints as enode
|
|
|
|
func (self peerAddr) String() string { |
|
|
|
func (self *peerAddr) String() string { |
|
|
|
var nodeid discover.NodeID |
|
|
|
var nodeid discover.NodeID |
|
|
|
copy(nodeid[:], self.ID) |
|
|
|
copy(nodeid[:], self.ID) |
|
|
|
return discover.NewNode(nodeid, self.IP, 0, self.Port).String() |
|
|
|
return discover.NewNode(nodeid, self.IP, 0, self.Port).String() |
|
|
@ -213,7 +213,7 @@ type peersMsgData struct { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// peers msg pretty printer
|
|
|
|
// peers msg pretty printer
|
|
|
|
func (self peersMsgData) String() string { |
|
|
|
func (self *peersMsgData) String() string { |
|
|
|
var from string |
|
|
|
var from string |
|
|
|
if self.from == nil { |
|
|
|
if self.from == nil { |
|
|
|
from = "ourselves" |
|
|
|
from = "ourselves" |
|
|
@ -227,7 +227,7 @@ func (self peersMsgData) String() string { |
|
|
|
return fmt.Sprintf("from: %v, Key: %x; ID: %v, Peers: %v", from, target, self.Id, self.Peers) |
|
|
|
return fmt.Sprintf("from: %v, Key: %x; ID: %v, Peers: %v", from, target, self.Id, self.Peers) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (self peersMsgData) setTimeout(t *time.Time) { |
|
|
|
func (self *peersMsgData) setTimeout(t *time.Time) { |
|
|
|
self.timeout = t |
|
|
|
self.timeout = t |
|
|
|
if t != nil { |
|
|
|
if t != nil { |
|
|
|
self.Timeout = uint64(t.UnixNano()) |
|
|
|
self.Timeout = uint64(t.UnixNano()) |
|
|
@ -236,15 +236,6 @@ func (self peersMsgData) setTimeout(t *time.Time) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (self peersMsgData) getTimeout() (t *time.Time) { |
|
|
|
|
|
|
|
if self.Timeout > 0 && self.timeout == nil { |
|
|
|
|
|
|
|
timeout := time.Unix(int64(self.Timeout), 0) |
|
|
|
|
|
|
|
t = &timeout |
|
|
|
|
|
|
|
self.timeout = t |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/* |
|
|
|
syncRequest |
|
|
|
syncRequest |
|
|
|
|
|
|
|
|
|
|
|