Skip to content

Commit

Permalink
DeadlineSettable -> DeadlineSettableConn
Browse files Browse the repository at this point in the history
  • Loading branch information
algorandskiy committed Jun 20, 2024
1 parent a35b5c5 commit f6dd7a4
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion agreement/fuzzer/networkFacade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ func (n *NetworkFacade) ReceiveMessage(sourceNode int, tag protocol.Tag, data []
n.pushPendingReceivedMessage()
}

func (n *NetworkFacade) Disconnect(sender network.DisconnectablePeer) {
func (n *NetworkFacade) Disconnect(sender network.DeadlineSettableConn) {
sourceNode := n.peerToNode[sender.(*facadePeer)]
n.fuzzer.Disconnect(n.nodeID, sourceNode)
}
Expand Down
2 changes: 1 addition & 1 deletion agreement/gossip/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (w *whiteholeNetwork) Relay(ctx context.Context, tag protocol.Tag, data []b
func (w *whiteholeNetwork) BroadcastSimple(tag protocol.Tag, data []byte) error {
return w.Broadcast(context.Background(), tag, data, true, nil)
}
func (w *whiteholeNetwork) Disconnect(badnode network.DisconnectablePeer) {
func (w *whiteholeNetwork) Disconnect(badnode network.DeadlineSettableConn) {
return
}
func (w *whiteholeNetwork) DisconnectPeers() {
Expand Down
2 changes: 1 addition & 1 deletion components/mocks/mockNetwork.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (network *MockNetwork) RequestConnectOutgoing(replace bool, quit <-chan str
}

// Disconnect - unused function
func (network *MockNetwork) Disconnect(badpeer network.DisconnectablePeer) {
func (network *MockNetwork) Disconnect(badpeer network.DeadlineSettableConn) {
}

// DisconnectPeers - unused function
Expand Down
4 changes: 2 additions & 2 deletions data/txHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ func (handler *TxHandler) dedupCanonical(unverifiedTxGroup []transactions.Signed
// - the key used for insertion if the message was not found in the cache
// - the capacity guard returned by the elastic rate limiter
// - a boolean indicating if the message was a duplicate or the sender is rate limited
func (handler *TxHandler) incomingMsgDupErlCheck(data []byte, sender network.DisconnectablePeer) (*crypto.Digest, *util.ErlCapacityGuard, bool) {
func (handler *TxHandler) incomingMsgDupErlCheck(data []byte, sender network.DeadlineSettableConn) (*crypto.Digest, *util.ErlCapacityGuard, bool) {
var msgKey *crypto.Digest
var capguard *util.ErlCapacityGuard
var isDup bool
Expand Down Expand Up @@ -681,7 +681,7 @@ func decodeMsg(data []byte) (unverifiedTxGroup []transactions.SignedTxn, consume
// incomingTxGroupDupRateLimit checks
// - if the incoming transaction group has been seen before after reencoding to canonical representation, and
// - if the sender is rate limited by the per-application rate limiter.
func (handler *TxHandler) incomingTxGroupDupRateLimit(unverifiedTxGroup []transactions.SignedTxn, encodedExpectedSize int, sender network.DisconnectablePeer) (*crypto.Digest, bool) {
func (handler *TxHandler) incomingTxGroupDupRateLimit(unverifiedTxGroup []transactions.SignedTxn, encodedExpectedSize int, sender network.DeadlineSettableConn) (*crypto.Digest, bool) {
var canonicalKey *crypto.Digest
if handler.txCanonicalCache != nil {
var isDup bool
Expand Down
2 changes: 1 addition & 1 deletion network/connPerfMon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func makeMsgPool(N int, peers []Peer) (out []IncomingMessage) {

addMsg := func(msgCount int) {
for i := 0; i < msgCount; i++ {
msg.Sender = peers[(int(msgIndex)+i)%len(peers)].(DisconnectablePeer)
msg.Sender = peers[(int(msgIndex)+i)%len(peers)].(DeadlineSettableConn)
timer += int64(7 * time.Nanosecond)
msg.Received = timer
out = append(out, msg)
Expand Down
8 changes: 4 additions & 4 deletions network/gossipNode.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (
// Peer opaque interface for referring to a neighbor in the network
type Peer interface{}

// DisconnectablePeer is a Peer with a long-living connection to a network that can be disconnected
type DisconnectablePeer interface {
// DeadlineSettableConn is a Peer with a long-living connection to a network that can be disconnected
type DeadlineSettableConn interface {
GetNetwork() GossipNode
}

Expand Down Expand Up @@ -62,7 +62,7 @@ type GossipNode interface {
Address() (string, bool)
Broadcast(ctx context.Context, tag protocol.Tag, data []byte, wait bool, except Peer) error
Relay(ctx context.Context, tag protocol.Tag, data []byte, wait bool, except Peer) error
Disconnect(badnode DisconnectablePeer)
Disconnect(badnode DeadlineSettableConn)
DisconnectPeers() // only used by testing

// RegisterHTTPHandler path accepts gorilla/mux path annotations
Expand Down Expand Up @@ -127,7 +127,7 @@ var outgoingMessagesBufferSize = int(

// IncomingMessage represents a message arriving from some peer in our p2p network
type IncomingMessage struct {
Sender DisconnectablePeer
Sender DeadlineSettableConn
Tag Tag
Data []byte
Err error
Expand Down
6 changes: 3 additions & 3 deletions network/hybridNetwork.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (n *HybridP2PNetwork) Relay(ctx context.Context, tag protocol.Tag, data []b
}

// Disconnect implements GossipNode
func (n *HybridP2PNetwork) Disconnect(badnode DisconnectablePeer) {
func (n *HybridP2PNetwork) Disconnect(badnode DeadlineSettableConn) {

Check warning on line 118 in network/hybridNetwork.go

View check run for this annotation

Codecov / codecov/patch

network/hybridNetwork.go#L118

Added line #L118 was not covered by tests
net := badnode.GetNetwork()
if net == n.p2pNetwork {
n.p2pNetwork.Disconnect(badnode)
Expand Down Expand Up @@ -180,13 +180,13 @@ func (n *HybridP2PNetwork) ClearHandlers() {
n.wsNetwork.ClearHandlers()
}

// RegisterProcessors adds to the set of given message handlers.
// RegisterProcessors adds to the set of given message processors.
func (n *HybridP2PNetwork) RegisterProcessors(dispatch []TaggedMessageProcessor) {
n.p2pNetwork.RegisterProcessors(dispatch)
n.wsNetwork.RegisterProcessors(dispatch)
}

// ClearProcessors deregisters all the existing message handlers.
// ClearProcessors deregisters all the existing message processors.
func (n *HybridP2PNetwork) ClearProcessors() {
n.p2pNetwork.ClearProcessors()
n.wsNetwork.ClearProcessors()
Expand Down
4 changes: 2 additions & 2 deletions network/p2pNetwork.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ func (n *P2PNetwork) Relay(ctx context.Context, tag protocol.Tag, data []byte, w
}

// Disconnect from a peer, probably due to protocol errors.
func (n *P2PNetwork) Disconnect(badpeer DisconnectablePeer) {
func (n *P2PNetwork) Disconnect(badpeer DeadlineSettableConn) {

Check warning on line 530 in network/p2pNetwork.go

View check run for this annotation

Codecov / codecov/patch

network/p2pNetwork.go#L530

Added line #L530 was not covered by tests
var peerID peer.ID
var wsp *wsPeer

Expand Down Expand Up @@ -555,7 +555,7 @@ func (n *P2PNetwork) Disconnect(badpeer DisconnectablePeer) {
}
}

func (n *P2PNetwork) disconnectThread(badnode DisconnectablePeer, reason disconnectReason) {
func (n *P2PNetwork) disconnectThread(badnode DeadlineSettableConn, reason disconnectReason) {

Check warning on line 558 in network/p2pNetwork.go

View check run for this annotation

Codecov / codecov/patch

network/p2pNetwork.go#L558

Added line #L558 was not covered by tests
defer n.wg.Done()
n.Disconnect(badnode) // ignores reason
}
Expand Down
6 changes: 3 additions & 3 deletions network/wsNetwork.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ type networkPeerManager interface {

// used by msgHandler
Broadcast(ctx context.Context, tag protocol.Tag, data []byte, wait bool, except Peer) error
disconnectThread(badnode DisconnectablePeer, reason disconnectReason)
disconnectThread(badnode DeadlineSettableConn, reason disconnectReason)
checkPeersConnectivity()
}

Expand Down Expand Up @@ -477,13 +477,13 @@ func (wn *WebsocketNetwork) RelayArray(ctx context.Context, tags []protocol.Tag,
return nil
}

func (wn *WebsocketNetwork) disconnectThread(badnode DisconnectablePeer, reason disconnectReason) {
func (wn *WebsocketNetwork) disconnectThread(badnode DeadlineSettableConn, reason disconnectReason) {
defer wn.wg.Done()
wn.disconnect(badnode, reason)
}

// Disconnect from a peer, probably due to protocol errors.
func (wn *WebsocketNetwork) Disconnect(node DisconnectablePeer) {
func (wn *WebsocketNetwork) Disconnect(node DeadlineSettableConn) {

Check warning on line 486 in network/wsNetwork.go

View check run for this annotation

Codecov / codecov/patch

network/wsNetwork.go#L486

Added line #L486 was not covered by tests
wn.disconnect(node, disconnectBadData)
}

Expand Down

0 comments on commit f6dd7a4

Please sign in to comment.