mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-20 05:14:35 +00:00
split outbound and inbound codecs encoded types (#2410)
Splits the inbound and outbound requests, for maintainability.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use crate::rpc::{Protocol, RPCRequest};
|
||||
use crate::rpc::{InboundRequest, Protocol};
|
||||
use fnv::FnvHashMap;
|
||||
use libp2p::PeerId;
|
||||
use std::convert::TryInto;
|
||||
@@ -185,7 +185,7 @@ impl RPCRateLimiter {
|
||||
pub fn allows<T: EthSpec>(
|
||||
&mut self,
|
||||
peer_id: &PeerId,
|
||||
request: &RPCRequest<T>,
|
||||
request: &InboundRequest<T>,
|
||||
) -> Result<(), RateLimitedErr> {
|
||||
let time_since_start = self.init_time.elapsed();
|
||||
let mut tokens = request.expected_responses().max(1);
|
||||
@@ -207,7 +207,7 @@ impl RPCRateLimiter {
|
||||
// 9 | 4
|
||||
// 10 | 5
|
||||
|
||||
if let RPCRequest::BlocksByRange(bbr_req) = request {
|
||||
if let InboundRequest::BlocksByRange(bbr_req) = request {
|
||||
let penalty_factor = (bbr_req.step as f64 / 5.0).powi(2) as u64 + 1;
|
||||
tokens *= penalty_factor;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user