29
29
import org .apache .logging .log4j .LogManager ;
30
30
import org .apache .logging .log4j .Logger ;
31
31
import tech .pegasys .teku .infrastructure .async .SafeFuture ;
32
- import tech .pegasys .teku .networking .p2p .libp2p .rpc .PeerRpcHandler ;
33
32
import tech .pegasys .teku .networking .p2p .libp2p .rpc .RpcHandler ;
33
+ import tech .pegasys .teku .networking .p2p .libp2p .rpc .ThrottlingRpcHandler ;
34
34
import tech .pegasys .teku .networking .p2p .network .PeerAddress ;
35
35
import tech .pegasys .teku .networking .p2p .peer .DisconnectReason ;
36
36
import tech .pegasys .teku .networking .p2p .peer .DisconnectRequestHandler ;
47
47
public class LibP2PPeer implements Peer {
48
48
private static final Logger LOG = LogManager .getLogger ();
49
49
50
- private final Map <RpcMethod <?, ?, ?>, PeerRpcHandler <?, ?, ?>> rpcHandlers ;
50
+ private final Map <RpcMethod <?, ?, ?>, ThrottlingRpcHandler <?, ?, ?>> rpcHandlers ;
51
51
private final ReputationManager reputationManager ;
52
52
private final Function <PeerId , Double > peerScoreFunction ;
53
53
private final Connection connection ;
@@ -74,7 +74,7 @@ public LibP2PPeer(
74
74
this .connection = connection ;
75
75
this .rpcHandlers =
76
76
rpcHandlers .stream ()
77
- .collect (Collectors .toMap (RpcHandler ::getRpcMethod , PeerRpcHandler ::new ));
77
+ .collect (Collectors .toMap (RpcHandler ::getRpcMethod , ThrottlingRpcHandler ::new ));
78
78
this .reputationManager = reputationManager ;
79
79
this .peerScoreFunction = peerScoreFunction ;
80
80
this .peerId = connection .secureSession ().getRemoteId ();
@@ -207,8 +207,8 @@ SafeFuture<RpcStreamController<TOutgoingHandler>> sendRequest(
207
207
final TRequest request ,
208
208
final RespHandler responseHandler ) {
209
209
@ SuppressWarnings ("unchecked" )
210
- final PeerRpcHandler <TOutgoingHandler , TRequest , RespHandler > rpcHandler =
211
- (PeerRpcHandler <TOutgoingHandler , TRequest , RespHandler >) rpcHandlers .get (rpcMethod );
210
+ final ThrottlingRpcHandler <TOutgoingHandler , TRequest , RespHandler > rpcHandler =
211
+ (ThrottlingRpcHandler <TOutgoingHandler , TRequest , RespHandler >) rpcHandlers .get (rpcMethod );
212
212
if (rpcHandler == null ) {
213
213
throw new IllegalArgumentException (
214
214
"Unknown rpc method invoked: " + String .join ("," , rpcMethod .getIds ()));
0 commit comments