mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 02:40:45 +00:00
p2p: added received at to peer message
p2p.Msg.ReceivedAt can be used for determining block propagation from begining to end.
This commit is contained in:
parent
9e63798d03
commit
01e3d694a6
2 changed files with 5 additions and 3 deletions
|
|
@ -22,9 +22,10 @@ import (
|
||||||
// structure, encode the payload into a byte array and create a
|
// structure, encode the payload into a byte array and create a
|
||||||
// separate Msg with a bytes.Reader as Payload for each send.
|
// separate Msg with a bytes.Reader as Payload for each send.
|
||||||
type Msg struct {
|
type Msg struct {
|
||||||
Code uint64
|
Code uint64
|
||||||
Size uint32 // size of the paylod
|
Size uint32 // size of the paylod
|
||||||
Payload io.Reader
|
Payload io.Reader
|
||||||
|
ReceivedAt time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode parses the RLP content of a message into
|
// Decode parses the RLP content of a message into
|
||||||
|
|
|
||||||
|
|
@ -177,6 +177,7 @@ func (p *Peer) readLoop(errc chan<- error) {
|
||||||
errc <- err
|
errc <- err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
msg.ReceivedAt = time.Now()
|
||||||
if err = p.handle(msg); err != nil {
|
if err = p.handle(msg); err != nil {
|
||||||
errc <- err
|
errc <- err
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue