Skip to content

Commit b942a4d

Browse files
authored
Merge pull request DMDcoin#197 from SurfingNerd/devp2p-fixes
i will solve failing Unit tests in later addition
2 parents 28276d5 + 7b7bb88 commit b942a4d

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

crates/ethcore/sync/src/chain/handler.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,9 @@ impl SyncHandler {
861861
.as_val::<H256>()
862862
.map_err(|_| DownloaderImportError::Invalid)?;
863863

864+
// todo: what if the Transaction is not new, and already in the chain?
865+
// see: https://github.com/DMDcoin/diamond-node/issues/196
866+
864867
if io.chain().queued_transaction(hash).is_none() {
865868
sync.peers
866869
.get_mut(&peer_id)

crates/ethcore/sync/src/chain/mod.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,7 +1419,10 @@ impl ChainSync {
14191419

14201420
// communicate with this peer in any case if we are on the same block.
14211421
// more about: https://github.com/DMDcoin/diamond-node/issues/173
1422-
let communicate_with_peer = chain_info.best_block_hash == peer_latest;
1422+
1423+
//let communicate_with_peer = chain_info.best_block_hash == peer_latest;
1424+
1425+
let communicate_with_peer = true;
14231426

14241427
// on a distributed real network, 3 seconds is about they physical minimum.
14251428
// therefore we "accept" other nodes to be 1 block behind - usually they are not!
@@ -1459,18 +1462,27 @@ impl ChainSync {
14591462
if self
14601463
.asking_pooled_transaction_overview
14611464
.get_last_fetched(hash)
1462-
.map_or(false, |t| t.elapsed().as_millis() > 300)
1465+
.map_or(true, |t| t.elapsed().as_millis() > 300)
14631466
{
14641467
to_send.insert(hash.clone());
14651468
self.asking_pooled_transaction_overview
14661469
.report_transaction_pooling(hash);
14671470
}
14681471
}
14691472

1470-
peer.unfetched_pooled_transactions
1471-
.retain(|u| !to_send.contains(u));
1472-
1473-
peer.asking_pooled_transactions = to_send.clone();
1473+
if !to_send.is_empty() {
1474+
peer.unfetched_pooled_transactions
1475+
.retain(|u| !to_send.contains(u));
1476+
1477+
// trace!(
1478+
// target: "sync",
1479+
// "Asking {} pooled transactions from peer {}: {:?}",
1480+
// to_send.len(),
1481+
// peer_id,
1482+
// to_send
1483+
// );
1484+
peer.asking_pooled_transactions = to_send.clone();
1485+
}
14741486
} else {
14751487
info!(
14761488
"we are already asking from peer {}: {} transactions",

crates/ethcore/sync/src/chain/propagator.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ impl ChainSync {
6565
blocks: &[H256],
6666
peers: &[PeerId],
6767
) -> usize {
68+
if peers.len() == 0 {
69+
return 0;
70+
}
6871
trace!(target: "sync", "Sending NewBlocks to {:?}", peers);
6972
let sent = peers.len();
7073
let mut send_packet = |io: &mut dyn SyncIo, rlp: Bytes| {
@@ -100,6 +103,9 @@ impl ChainSync {
100103
io: &mut dyn SyncIo,
101104
peers: &[PeerId],
102105
) -> usize {
106+
if peers.len() == 0 {
107+
return 0;
108+
}
103109
trace!(target: "sync", "Sending NewHashes to {:?}", peers);
104110
let last_parent = *io.chain().best_block_header().parent_hash();
105111
let best_block_hash = chain_info.best_block_hash;
@@ -226,14 +232,15 @@ impl ChainSync {
226232
let peer_info = self.peers.get_mut(&peer_id)
227233
.expect("peer_id is form peers; peers is result of select_peers_for_transactions; select_peers_for_transactions selects peers from self.peers; qed");
228234

229-
warn!(target: "sync", "peer_info.protocol_version: {:?}", peer_info.protocol_version);
230-
231235
let mut id: Option<ethereum_types::H512> = None;
232236
let mut is_hashes = false;
233237

234238
if let Some(session_info) = io.peer_session_info(peer_id) {
235239
is_hashes = session_info.is_pooled_transactions_capable();
236240
id = session_info.id;
241+
} else {
242+
warn!(target: "sync", "no peer session info available: could not detect if peer is capable of eip-2464 transaction gossiping");
243+
continue;
237244
}
238245

239246
// Send all transactions, if the peer doesn't know about anything

0 commit comments

Comments
 (0)