Make Capabilities struct
Copy (#9372)
This commit is contained in:
parent
ee5ed44761
commit
b2cf5d2958
@ -823,7 +823,7 @@ impl LightProtocol {
|
|||||||
self.peers.write().insert(*peer, Mutex::new(Peer {
|
self.peers.write().insert(*peer, Mutex::new(Peer {
|
||||||
local_credits: local_flow.create_credits(),
|
local_credits: local_flow.create_credits(),
|
||||||
status: status.clone(),
|
status: status.clone(),
|
||||||
capabilities: capabilities.clone(),
|
capabilities,
|
||||||
remote_flow: remote_flow,
|
remote_flow: remote_flow,
|
||||||
sent_head: pending.sent_head,
|
sent_head: pending.sent_head,
|
||||||
last_update: pending.last_update,
|
last_update: pending.last_update,
|
||||||
|
@ -169,7 +169,7 @@ impl Status {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Peer capabilities.
|
/// Peer capabilities.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub struct Capabilities {
|
pub struct Capabilities {
|
||||||
/// Whether this peer can serve headers
|
/// Whether this peer can serve headers
|
||||||
pub serve_headers: bool,
|
pub serve_headers: bool,
|
||||||
|
@ -222,7 +222,7 @@ fn status(chain_info: BlockChainInfo) -> Status {
|
|||||||
fn handshake_expected() {
|
fn handshake_expected() {
|
||||||
let capabilities = capabilities();
|
let capabilities = capabilities();
|
||||||
|
|
||||||
let (provider, proto) = setup(capabilities.clone());
|
let (provider, proto) = setup(capabilities);
|
||||||
|
|
||||||
let status = status(provider.client.chain_info());
|
let status = status(provider.client.chain_info());
|
||||||
|
|
||||||
@ -236,7 +236,7 @@ fn handshake_expected() {
|
|||||||
fn genesis_mismatch() {
|
fn genesis_mismatch() {
|
||||||
let capabilities = capabilities();
|
let capabilities = capabilities();
|
||||||
|
|
||||||
let (provider, proto) = setup(capabilities.clone());
|
let (provider, proto) = setup(capabilities);
|
||||||
|
|
||||||
let mut status = status(provider.client.chain_info());
|
let mut status = status(provider.client.chain_info());
|
||||||
status.genesis_hash = H256::default();
|
status.genesis_hash = H256::default();
|
||||||
@ -250,7 +250,7 @@ fn genesis_mismatch() {
|
|||||||
fn credit_overflow() {
|
fn credit_overflow() {
|
||||||
let capabilities = capabilities();
|
let capabilities = capabilities();
|
||||||
|
|
||||||
let (provider, proto) = setup(capabilities.clone());
|
let (provider, proto) = setup(capabilities);
|
||||||
|
|
||||||
let status = status(provider.client.chain_info());
|
let status = status(provider.client.chain_info());
|
||||||
|
|
||||||
@ -283,7 +283,7 @@ fn credit_overflow() {
|
|||||||
fn get_block_headers() {
|
fn get_block_headers() {
|
||||||
let capabilities = capabilities();
|
let capabilities = capabilities();
|
||||||
|
|
||||||
let (provider, proto) = setup(capabilities.clone());
|
let (provider, proto) = setup(capabilities);
|
||||||
let flow_params = proto.flow_params.read().clone();
|
let flow_params = proto.flow_params.read().clone();
|
||||||
|
|
||||||
let cur_status = status(provider.client.chain_info());
|
let cur_status = status(provider.client.chain_info());
|
||||||
@ -335,7 +335,7 @@ fn get_block_headers() {
|
|||||||
fn get_block_bodies() {
|
fn get_block_bodies() {
|
||||||
let capabilities = capabilities();
|
let capabilities = capabilities();
|
||||||
|
|
||||||
let (provider, proto) = setup(capabilities.clone());
|
let (provider, proto) = setup(capabilities);
|
||||||
let flow_params = proto.flow_params.read().clone();
|
let flow_params = proto.flow_params.read().clone();
|
||||||
|
|
||||||
let cur_status = status(provider.client.chain_info());
|
let cur_status = status(provider.client.chain_info());
|
||||||
@ -383,7 +383,7 @@ fn get_block_bodies() {
|
|||||||
fn get_block_receipts() {
|
fn get_block_receipts() {
|
||||||
let capabilities = capabilities();
|
let capabilities = capabilities();
|
||||||
|
|
||||||
let (provider, proto) = setup(capabilities.clone());
|
let (provider, proto) = setup(capabilities);
|
||||||
let flow_params = proto.flow_params.read().clone();
|
let flow_params = proto.flow_params.read().clone();
|
||||||
|
|
||||||
let cur_status = status(provider.client.chain_info());
|
let cur_status = status(provider.client.chain_info());
|
||||||
@ -438,7 +438,7 @@ fn get_block_receipts() {
|
|||||||
fn get_state_proofs() {
|
fn get_state_proofs() {
|
||||||
let capabilities = capabilities();
|
let capabilities = capabilities();
|
||||||
|
|
||||||
let (provider, proto) = setup(capabilities.clone());
|
let (provider, proto) = setup(capabilities);
|
||||||
let flow_params = proto.flow_params.read().clone();
|
let flow_params = proto.flow_params.read().clone();
|
||||||
|
|
||||||
let provider = TestProvider(provider);
|
let provider = TestProvider(provider);
|
||||||
@ -497,7 +497,7 @@ fn get_state_proofs() {
|
|||||||
fn get_contract_code() {
|
fn get_contract_code() {
|
||||||
let capabilities = capabilities();
|
let capabilities = capabilities();
|
||||||
|
|
||||||
let (provider, proto) = setup(capabilities.clone());
|
let (provider, proto) = setup(capabilities);
|
||||||
let flow_params = proto.flow_params.read().clone();
|
let flow_params = proto.flow_params.read().clone();
|
||||||
|
|
||||||
let cur_status = status(provider.client.chain_info());
|
let cur_status = status(provider.client.chain_info());
|
||||||
@ -540,7 +540,7 @@ fn get_contract_code() {
|
|||||||
fn epoch_signal() {
|
fn epoch_signal() {
|
||||||
let capabilities = capabilities();
|
let capabilities = capabilities();
|
||||||
|
|
||||||
let (provider, proto) = setup(capabilities.clone());
|
let (provider, proto) = setup(capabilities);
|
||||||
let flow_params = proto.flow_params.read().clone();
|
let flow_params = proto.flow_params.read().clone();
|
||||||
|
|
||||||
let cur_status = status(provider.client.chain_info());
|
let cur_status = status(provider.client.chain_info());
|
||||||
@ -583,7 +583,7 @@ fn epoch_signal() {
|
|||||||
fn proof_of_execution() {
|
fn proof_of_execution() {
|
||||||
let capabilities = capabilities();
|
let capabilities = capabilities();
|
||||||
|
|
||||||
let (provider, proto) = setup(capabilities.clone());
|
let (provider, proto) = setup(capabilities);
|
||||||
let flow_params = proto.flow_params.read().clone();
|
let flow_params = proto.flow_params.read().clone();
|
||||||
|
|
||||||
let cur_status = status(provider.client.chain_info());
|
let cur_status = status(provider.client.chain_info());
|
||||||
@ -643,7 +643,7 @@ fn id_guard() {
|
|||||||
|
|
||||||
let capabilities = capabilities();
|
let capabilities = capabilities();
|
||||||
|
|
||||||
let (provider, proto) = setup(capabilities.clone());
|
let (provider, proto) = setup(capabilities);
|
||||||
let flow_params = proto.flow_params.read().clone();
|
let flow_params = proto.flow_params.read().clone();
|
||||||
|
|
||||||
let req_id_1 = ReqId(5143);
|
let req_id_1 = ReqId(5143);
|
||||||
@ -666,7 +666,7 @@ fn id_guard() {
|
|||||||
proto.peers.write().insert(peer_id, ::parking_lot::Mutex::new(Peer {
|
proto.peers.write().insert(peer_id, ::parking_lot::Mutex::new(Peer {
|
||||||
local_credits: flow_params.create_credits(),
|
local_credits: flow_params.create_credits(),
|
||||||
status: status(provider.client.chain_info()),
|
status: status(provider.client.chain_info()),
|
||||||
capabilities: capabilities.clone(),
|
capabilities,
|
||||||
remote_flow: Some((flow_params.create_credits(), (&*flow_params).clone())),
|
remote_flow: Some((flow_params.create_credits(), (&*flow_params).clone())),
|
||||||
sent_head: provider.client.chain_info().best_block_hash,
|
sent_head: provider.client.chain_info().best_block_hash,
|
||||||
last_update: Instant::now(),
|
last_update: Instant::now(),
|
||||||
@ -723,7 +723,7 @@ fn id_guard() {
|
|||||||
fn get_transaction_index() {
|
fn get_transaction_index() {
|
||||||
let capabilities = capabilities();
|
let capabilities = capabilities();
|
||||||
|
|
||||||
let (provider, proto) = setup(capabilities.clone());
|
let (provider, proto) = setup(capabilities);
|
||||||
let flow_params = proto.flow_params.read().clone();
|
let flow_params = proto.flow_params.read().clone();
|
||||||
|
|
||||||
let cur_status = status(provider.client.chain_info());
|
let cur_status = status(provider.client.chain_info());
|
||||||
|
@ -418,7 +418,7 @@ impl Handler for OnDemand {
|
|||||||
) -> PeerStatus {
|
) -> PeerStatus {
|
||||||
self.peers.write().insert(
|
self.peers.write().insert(
|
||||||
ctx.peer(),
|
ctx.peer(),
|
||||||
Peer { status: status.clone(), capabilities: capabilities.clone() }
|
Peer { status: status.clone(), capabilities: *capabilities }
|
||||||
);
|
);
|
||||||
self.attempt_dispatch(ctx.as_basic());
|
self.attempt_dispatch(ctx.as_basic());
|
||||||
PeerStatus::Kept
|
PeerStatus::Kept
|
||||||
|
Loading…
Reference in New Issue
Block a user