declone and close the door (#12035)

* declone and close the door

* cargo fmt

* remove brackets
This commit is contained in:
Squirrel
2022-08-15 20:38:36 +01:00
committed by GitHub
parent 9c2a2495fe
commit a68a80fbae
72 changed files with 344 additions and 512 deletions
+20 -20
View File
@@ -2614,15 +2614,15 @@ mod test {
let (b1_hash, b1_number) = new_blocks(50);
// add 2 peers at blocks that we don't have locally
sync.new_peer(peer_id1.clone(), Hash::random(), 42).unwrap();
sync.new_peer(peer_id2.clone(), Hash::random(), 10).unwrap();
sync.new_peer(peer_id1, Hash::random(), 42).unwrap();
sync.new_peer(peer_id2, Hash::random(), 10).unwrap();
// we wil send block requests to these peers
// for these blocks we don't know about
assert!(sync.block_requests().all(|(p, _)| { *p == peer_id1 || *p == peer_id2 }));
// add a new peer at a known block
sync.new_peer(peer_id3.clone(), b1_hash, b1_number).unwrap();
sync.new_peer(peer_id3, b1_hash, b1_number).unwrap();
// we request a justification for a block we have locally
sync.request_justification(&b1_hash, b1_number);
@@ -2673,7 +2673,7 @@ mod test {
data: Some(Vec::new()),
};
sync.push_block_announce_validation(peer_id.clone(), header.hash(), block_annnounce, true);
sync.push_block_announce_validation(*peer_id, header.hash(), block_annnounce, true);
// Poll until we have procssed the block announcement
block_on(poll_fn(|cx| loop {
@@ -2790,8 +2790,8 @@ mod test {
let block3_fork = build_block_at(block2.hash(), false);
// Add two peers which are on block 1.
sync.new_peer(peer_id1.clone(), block1.hash(), 1).unwrap();
sync.new_peer(peer_id2.clone(), block1.hash(), 1).unwrap();
sync.new_peer(peer_id1, block1.hash(), 1).unwrap();
sync.new_peer(peer_id2, block1.hash(), 1).unwrap();
// Tell sync that our best block is 3.
sync.update_chain_info(&block3.hash(), 3);
@@ -2885,9 +2885,9 @@ mod test {
let best_block = blocks.last().unwrap().clone();
// Connect the node we will sync from
sync.new_peer(peer_id1.clone(), best_block.hash(), *best_block.header().number())
sync.new_peer(peer_id1, best_block.hash(), *best_block.header().number())
.unwrap();
sync.new_peer(peer_id2.clone(), info.best_hash, 0).unwrap();
sync.new_peer(peer_id2, info.best_hash, 0).unwrap();
let mut best_block_num = 0;
while best_block_num < MAX_DOWNLOAD_AHEAD {
@@ -2922,9 +2922,9 @@ mod test {
.map(|b| {
(
Ok(BlockImportStatus::ImportedUnknown(
b.header().number().clone(),
*b.header().number(),
Default::default(),
Some(peer_id1.clone()),
Some(peer_id1),
)),
b.hash(),
)
@@ -3034,7 +3034,7 @@ mod test {
let common_block = blocks[MAX_BLOCKS_TO_LOOK_BACKWARDS as usize / 2].clone();
// Connect the node we will sync from
sync.new_peer(peer_id1.clone(), common_block.hash(), *common_block.header().number())
sync.new_peer(peer_id1, common_block.hash(), *common_block.header().number())
.unwrap();
send_block_announce(fork_blocks.last().unwrap().header().clone(), &peer_id1, &mut sync);
@@ -3059,7 +3059,7 @@ mod test {
}
// Now request and import the fork.
let mut best_block_num = finalized_block.header().number().clone() as u32;
let mut best_block_num = *finalized_block.header().number() as u32;
while best_block_num < *fork_blocks.last().unwrap().header().number() as u32 - 1 {
let request = get_block_request(
&mut sync,
@@ -3092,9 +3092,9 @@ mod test {
.map(|b| {
(
Ok(BlockImportStatus::ImportedUnknown(
b.header().number().clone(),
*b.header().number(),
Default::default(),
Some(peer_id1.clone()),
Some(peer_id1),
)),
b.hash(),
)
@@ -3165,7 +3165,7 @@ mod test {
let common_block = blocks[MAX_BLOCKS_TO_LOOK_BACKWARDS as usize / 2].clone();
// Connect the node we will sync from
sync.new_peer(peer_id1.clone(), common_block.hash(), *common_block.header().number())
sync.new_peer(peer_id1, common_block.hash(), *common_block.header().number())
.unwrap();
send_block_announce(fork_blocks.last().unwrap().header().clone(), &peer_id1, &mut sync);
@@ -3190,7 +3190,7 @@ mod test {
}
// Now request and import the fork.
let mut best_block_num = finalized_block.header().number().clone() as u32;
let mut best_block_num = *finalized_block.header().number() as u32;
let mut request = get_block_request(
&mut sync,
FromBlock::Number(MAX_BLOCKS_TO_REQUEST as u64 + best_block_num as u64),
@@ -3231,9 +3231,9 @@ mod test {
.map(|b| {
(
Ok(BlockImportStatus::ImportedUnknown(
b.header().number().clone(),
*b.header().number(),
Default::default(),
Some(peer_id1.clone()),
Some(peer_id1),
)),
b.hash(),
)
@@ -3288,7 +3288,7 @@ mod test {
let peer_id1 = PeerId::random();
let common_block = blocks[1].clone();
// Connect the node we will sync from
sync.new_peer(peer_id1.clone(), common_block.hash(), *common_block.header().number())
sync.new_peer(peer_id1, common_block.hash(), *common_block.header().number())
.unwrap();
// Create a "new" header and announce it
@@ -3320,7 +3320,7 @@ mod test {
let peer_id1 = PeerId::random();
let best_block = blocks[3].clone();
sync.new_peer(peer_id1.clone(), best_block.hash(), *best_block.header().number())
sync.new_peer(peer_id1, best_block.hash(), *best_block.header().number())
.unwrap();
sync.peers.get_mut(&peer_id1).unwrap().state = PeerSyncState::Available;