diff --git a/ethcore/sync/src/chain/propagator.rs b/ethcore/sync/src/chain/propagator.rs index 9cd3981b6..fd6f2c0c4 100644 --- a/ethcore/sync/src/chain/propagator.rs +++ b/ethcore/sync/src/chain/propagator.rs @@ -48,16 +48,24 @@ fn accepts_service_transaction(client_id: &str) -> bool { // Parity versions starting from this will accept service-transactions const SERVICE_TRANSACTIONS_VERSION: (u32, u32) = (1u32, 6u32); // Parity client string prefix + const LEGACY_CLIENT_ID_PREFIX: &'static str = "Parity/v"; const PARITY_CLIENT_ID_PREFIX: &'static str = "Parity-Ethereum/v"; - if !client_id.starts_with(PARITY_CLIENT_ID_PREFIX) { - return false; - } + if client_id.starts_with(LEGACY_CLIENT_ID_PREFIX) { + let ver: Vec = client_id[LEGACY_CLIENT_ID_PREFIX.len()..].split('.') + .take(2) + .filter_map(|s| s.parse().ok()) + .collect(); + ver.len() == 2 && (ver[0] > SERVICE_TRANSACTIONS_VERSION.0 || (ver[0] == SERVICE_TRANSACTIONS_VERSION.0 && ver[1] >= SERVICE_TRANSACTIONS_VERSION.1)) + } else if client_id.starts_with(PARITY_CLIENT_ID_PREFIX) { let ver: Vec = client_id[PARITY_CLIENT_ID_PREFIX.len()..].split('.') .take(2) .filter_map(|s| s.parse().ok()) .collect(); - ver.len() == 2 && (ver[0] > SERVICE_TRANSACTIONS_VERSION.0 || (ver[0] == SERVICE_TRANSACTIONS_VERSION.0 && ver[1] >= SERVICE_TRANSACTIONS_VERSION.1)) + ver.len() == 2 && (ver[0] > SERVICE_TRANSACTIONS_VERSION.0 || (ver[0] == SERVICE_TRANSACTIONS_VERSION.0 && ver[1] >= SERVICE_TRANSACTIONS_VERSION.1)) + } else { + return false; + } } /// The Chain Sync Propagator: propagates data to peers @@ -580,7 +588,7 @@ mod tests { io.peers_info.insert(2, "Parity-Ethereum/v2.6".to_owned()); // and peer#3 is Parity, discarding service transactions insert_dummy_peer(&mut sync, 3, block_hash); - io.peers_info.insert(3, "Parity-Ethereum/v2.5".to_owned()); + io.peers_info.insert(3, "Parity/v1.5".to_owned()); // and peer#4 is Parity, accepting service transactions insert_dummy_peer(&mut sync, 4, block_hash); io.peers_info.insert(4, "Parity-Ethereum/v2.7.3-ABCDEFGH".to_owned());