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

[beta] Avoid re-broadcasting transactions on each block #4047

Merged
merged 3 commits into from
Jan 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ethcore/src/blockchain/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub trait BlockProvider {
fn blocks_with_bloom(&self, bloom: &H2048, from_block: BlockNumber, to_block: BlockNumber) -> Vec<BlockNumber>;

/// Returns logs matching given filter.
fn logs<F>(&self, mut blocks: Vec<BlockNumber>, matches: F, limit: Option<usize>) -> Vec<LocalizedLogEntry>
fn logs<F>(&self, blocks: Vec<BlockNumber>, matches: F, limit: Option<usize>) -> Vec<LocalizedLogEntry>
where F: Fn(&LogEntry) -> bool, Self: Sized;
}

Expand Down
14 changes: 5 additions & 9 deletions sync/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1995,9 +1995,6 @@ impl ChainSync {
trace!(target: "sync", "Bad blocks in the queue, restarting");
self.restart(io);
}
for peer_info in self.peers.values_mut() {
peer_info.last_sent_transactions.clear();
}
}
}

Expand Down Expand Up @@ -2334,7 +2331,7 @@ mod tests {
}

#[test]
fn propagates_transactions_again_after_new_block() {
fn should_not_propagate_transactions_again_after_new_block() {
let mut client = TestBlockChainClient::new();
client.add_blocks(100, EachBlockWith::Uncle);
client.insert_transaction_to_queue();
Expand All @@ -2347,14 +2344,13 @@ mod tests {
// Try to propagate same transactions for the second time
let peer_count2 = sync.propagate_new_transactions(&mut io);

// 2 message should be send
assert_eq!(2, io.queue.len());
// 1 peer should be updated twice
// 1 message should be send
assert_eq!(1, io.queue.len());
// 1 peer should be updated only for the first time
assert_eq!(1, peer_count);
assert_eq!(1, peer_count2);
assert_eq!(0, peer_count2);
// TRANSACTIONS_PACKET
assert_eq!(0x02, io.queue[0].packet_id);
assert_eq!(0x02, io.queue[1].packet_id);
}

#[test]
Expand Down