swarm/network/simulation: use simulations.Event instead p2p.PeerEvent (#18098)
This commit is contained in:
committed by
Viktor Trón
parent
b91766fe6d
commit
324027640b
@ -24,7 +24,6 @@ import (
|
||||
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/node"
|
||||
"github.com/ethereum/go-ethereum/p2p"
|
||||
"github.com/ethereum/go-ethereum/p2p/simulations/adapters"
|
||||
"github.com/ethereum/go-ethereum/swarm/network"
|
||||
"github.com/ethereum/go-ethereum/swarm/network/simulation"
|
||||
@ -87,7 +86,7 @@ func ExampleSimulation_PeerEvents() {
|
||||
log.Error("peer event", "err", e.Error)
|
||||
continue
|
||||
}
|
||||
log.Info("peer event", "node", e.NodeID, "peer", e.Event.Peer, "msgcode", e.Event.MsgCode)
|
||||
log.Info("peer event", "node", e.NodeID, "peer", e.PeerID, "type", e.Event.Type)
|
||||
}
|
||||
}()
|
||||
}
|
||||
@ -100,7 +99,7 @@ func ExampleSimulation_PeerEvents_disconnections() {
|
||||
disconnections := sim.PeerEvents(
|
||||
context.Background(),
|
||||
sim.NodeIDs(),
|
||||
simulation.NewPeerEventsFilter().Type(p2p.PeerEventTypeDrop),
|
||||
simulation.NewPeerEventsFilter().Drop(),
|
||||
)
|
||||
|
||||
go func() {
|
||||
@ -109,7 +108,7 @@ func ExampleSimulation_PeerEvents_disconnections() {
|
||||
log.Error("peer drop", "err", d.Error)
|
||||
continue
|
||||
}
|
||||
log.Warn("peer drop", "node", d.NodeID, "peer", d.Event.Peer)
|
||||
log.Warn("peer drop", "node", d.NodeID, "peer", d.PeerID)
|
||||
}
|
||||
}()
|
||||
}
|
||||
@ -124,8 +123,8 @@ func ExampleSimulation_PeerEvents_multipleFilters() {
|
||||
context.Background(),
|
||||
sim.NodeIDs(),
|
||||
// Watch when bzz messages 1 and 4 are received.
|
||||
simulation.NewPeerEventsFilter().Type(p2p.PeerEventTypeMsgRecv).Protocol("bzz").MsgCode(1),
|
||||
simulation.NewPeerEventsFilter().Type(p2p.PeerEventTypeMsgRecv).Protocol("bzz").MsgCode(4),
|
||||
simulation.NewPeerEventsFilter().ReceivedMessages().Protocol("bzz").MsgCode(1),
|
||||
simulation.NewPeerEventsFilter().ReceivedMessages().Protocol("bzz").MsgCode(4),
|
||||
)
|
||||
|
||||
go func() {
|
||||
@ -134,7 +133,7 @@ func ExampleSimulation_PeerEvents_multipleFilters() {
|
||||
log.Error("bzz message", "err", m.Error)
|
||||
continue
|
||||
}
|
||||
log.Info("bzz message", "node", m.NodeID, "peer", m.Event.Peer)
|
||||
log.Info("bzz message", "node", m.NodeID, "peer", m.PeerID)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
Reference in New Issue
Block a user