فهرست منبع

p2p: added received at to peer message

p2p.Msg.ReceivedAt can be used for determining block propagation from
begining to end.
obscuren 10 سال پیش
والد
کامیت
01e3d694a6
2فایلهای تغییر یافته به همراه5 افزوده شده و 3 حذف شده
  1. 4 3
      p2p/message.go
  2. 1 0
      p2p/peer.go

+ 4 - 3
p2p/message.go

@@ -22,9 +22,10 @@ import (
 // structure, encode the payload into a byte array and create a
 // separate Msg with a bytes.Reader as Payload for each send.
 type Msg struct {
-	Code    uint64
-	Size    uint32 // size of the paylod
-	Payload io.Reader
+	Code       uint64
+	Size       uint32 // size of the paylod
+	Payload    io.Reader
+	ReceivedAt time.Time
 }
 
 // Decode parses the RLP content of a message into

+ 1 - 0
p2p/peer.go

@@ -177,6 +177,7 @@ func (p *Peer) readLoop(errc chan<- error) {
 			errc <- err
 			return
 		}
+		msg.ReceivedAt = time.Now()
 		if err = p.handle(msg); err != nil {
 			errc <- err
 			return