Skip to content

Commit

Permalink
Revert "p2p/simulations/examples: use atomic.Int64 (ethereum#27861)"
Browse files Browse the repository at this point in the history
This reverts commit 7b3e2ee.
  • Loading branch information
devopsbo3 committed Nov 10, 2023
1 parent b498503 commit ac84474
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions p2p/simulations/examples/ping-pong.go
Expand Up @@ -91,7 +91,7 @@ func main() {
type pingPongService struct {
id enode.ID
log log.Logger
received atomic.Int64
received int64
}

func newPingPongService(id enode.ID) *pingPongService {
Expand Down Expand Up @@ -125,7 +125,7 @@ func (p *pingPongService) Info() interface{} {
return struct {
Received int64 `json:"received"`
}{
p.received.Load(),
atomic.LoadInt64(&p.received),
}
}

Expand Down Expand Up @@ -162,7 +162,7 @@ func (p *pingPongService) Run(peer *p2p.Peer, rw p2p.MsgReadWriter) error {
return
}
log.Info("received message", "msg.code", msg.Code, "msg.payload", string(payload))
p.received.Add(1)
atomic.AddInt64(&p.received, 1)
if msg.Code == pingMsgCode {
log.Info("sending pong")
go p2p.Send(rw, pongMsgCode, "PONG")
Expand Down

0 comments on commit ac84474

Please sign in to comment.