Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Fix rebroadcast panic #4084

Merged
merged 6 commits into from
Jan 9, 2017
Merged

Fix rebroadcast panic #4084

merged 6 commits into from
Jan 9, 2017

Conversation

keorn
Copy link

@keorn keorn commented Jan 8, 2017

No description provided.

@keorn keorn added A0-pleasereview 🤓 Pull request needs code review. M4-core ⛓ Core client code / Rust. labels Jan 8, 2017
for _ in 0..peers {
let peer = random.gen_range(0, len);
self.peers.values_mut().nth(peer).map(|mut peer_info| {
let peers: Vec<PeerId> = ChainSync::select_random_peers(&self.peers.keys().cloned().collect::<Vec<PeerId>>())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think Vec<_> might be more idiomatic...

@gavofyork gavofyork added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jan 8, 2017
.take(3)
.collect();
trace!(target: "sync", "Re-broadcasting transactions to random peers: {:?}", peers);
for peer in peers {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can avoid the allocation by moving the .into_iter().take portion to here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did it for tracing, will do though

@keorn
Copy link
Author

keorn commented Jan 8, 2017

ethcore_dapps fail seems unrelated

self.peers.values_mut().nth(peer).map(|mut peer_info| {
let peers: Vec<PeerId> = ChainSync::select_random_peers(&self.peers.keys().cloned().collect::<Vec<_>>());
trace!(target: "sync", "Re-broadcasting transactions to random peers.");
for peer in peers.iter().take(3) {
Copy link
Collaborator

@tomusdrw tomusdrw Jan 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous solution was sending to 0-2 peers after each block, current is sending to 3 peers after each block.

I think it would be better to keep average number the same, and perhaps to send only to one peer on each block (we can also get rid of unnecessary allocation in such case):

if !is_syncing && !enacted.is_empty() && !self.peers.is_empty() {
 let peer = random::new().get_rng(0, self.peers.len());
 ...
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm good with deterministic behaviour, just think that 3 peers at block might be a little bit too much (transactions will be rebroadcasted too often), that's why I suggested to send to only 1 peer - in such case we won't have two peers selected twice hence we can get rid of the allocation.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 1a3c30e on fix-rebroadcast into ** on master**.

@gavofyork gavofyork merged commit 8d256b2 into master Jan 9, 2017
@gavofyork gavofyork deleted the fix-rebroadcast branch January 9, 2017 11:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well. M4-core ⛓ Core client code / Rust.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants