Dynamically adjust PIP request costs based on gathered data (#5603)
* beginnings of load timer * initial load timer implementation * saturating adds * create flow params from distribution * update request credits and acknowledgement * mark cumulative cost dead code * fix compilation * tests * supply load share and other params to lightprotocol params * add file store * fix ethsync compilation * reshuffle constants
This commit is contained in:
committed by
Arkadiy Paronyan
parent
a8d99ae465
commit
aa41b48ba0
@@ -195,21 +195,33 @@ pub struct EthSync {
|
||||
impl EthSync {
|
||||
/// Creates and register protocol with the network service
|
||||
pub fn new(params: Params) -> Result<Arc<EthSync>, NetworkError> {
|
||||
const MAX_LIGHTSERV_LOAD: f64 = 0.5;
|
||||
|
||||
let pruning_info = params.chain.pruning_info();
|
||||
let light_proto = match params.config.serve_light {
|
||||
false => None,
|
||||
true => Some({
|
||||
let light_params = LightParams {
|
||||
let sample_store = params.network_config.net_config_path
|
||||
.clone()
|
||||
.map(::std::path::PathBuf::from)
|
||||
.map(|mut p| { p.push("request_timings"); light_net::FileStore(p) })
|
||||
.map(|store| Box::new(store) as Box<_>);
|
||||
|
||||
let mut light_params = LightParams {
|
||||
network_id: params.config.network_id,
|
||||
flow_params: Default::default(),
|
||||
config: Default::default(),
|
||||
capabilities: Capabilities {
|
||||
serve_headers: true,
|
||||
serve_chain_since: Some(pruning_info.earliest_chain),
|
||||
serve_state_since: Some(pruning_info.earliest_state),
|
||||
tx_relay: true,
|
||||
},
|
||||
sample_store: sample_store,
|
||||
};
|
||||
|
||||
let max_peers = ::std::cmp::min(params.network_config.max_peers, 1);
|
||||
light_params.config.load_share = MAX_LIGHTSERV_LOAD / max_peers as f64;
|
||||
|
||||
let mut light_proto = LightProtocol::new(params.provider, light_params);
|
||||
light_proto.add_handler(Arc::new(TxRelay(params.chain.clone())));
|
||||
|
||||
@@ -686,13 +698,14 @@ impl LightSync {
|
||||
let (sync, light_proto) = {
|
||||
let light_params = LightParams {
|
||||
network_id: params.network_id,
|
||||
flow_params: Default::default(), // or `None`?
|
||||
config: Default::default(),
|
||||
capabilities: Capabilities {
|
||||
serve_headers: false,
|
||||
serve_chain_since: None,
|
||||
serve_state_since: None,
|
||||
tx_relay: false,
|
||||
},
|
||||
sample_store: None,
|
||||
};
|
||||
|
||||
let mut light_proto = LightProtocol::new(params.client.clone(), light_params);
|
||||
|
||||
Reference in New Issue
Block a user