Forgotten testnet1 cherries (#475)
* Very quick peer banning endpoint, helps with #406 * Ping heights (#407) * add height to ping/ping * reformat output * fix p2p test * Fix orphan handling, not related to current head. Fixes #412 * Check before borrow, fixes #267 * Not finding an output commit in pos is an AlreadySpent * Fix race condition, sending before conn is ready * Explicit error for unknown pos of a forked block * Remove config outdated tests. Fix #333 * Check ref and try before borrow, fix #400 * We do not want to sync with old peers anyway * Hide cargo compiler warning for unused NoopAdapter and unused test code. Add TODOs
This commit is contained in:
committed by
Ignotus Peverell
parent
bffd955c26
commit
17d5898677
+10
-6
@@ -67,11 +67,11 @@ impl Protocol for ProtocolV1 {
|
||||
|
||||
/// Sends a ping message to the remote peer. Will panic if handle has never
|
||||
/// been called on this protocol.
|
||||
fn send_ping(&self, total_difficulty: Difficulty) -> Result<(), Error> {
|
||||
fn send_ping(&self, total_difficulty: Difficulty, height: u64) -> Result<(), Error> {
|
||||
self.send_request(
|
||||
Type::Ping,
|
||||
Type::Pong,
|
||||
&Ping { total_difficulty },
|
||||
&Ping { total_difficulty, height },
|
||||
None,
|
||||
)
|
||||
}
|
||||
@@ -128,7 +128,11 @@ impl ProtocolV1 {
|
||||
body: &W,
|
||||
expect_resp: Option<Hash>,
|
||||
) -> Result<(), Error> {
|
||||
self.conn.borrow().send_request(t, rt, body, expect_resp)
|
||||
if self.conn.is_initialized() {
|
||||
self.conn.borrow().send_request(t, rt, body, expect_resp)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,8 +146,8 @@ fn handle_payload(
|
||||
match header.msg_type {
|
||||
Type::Ping => {
|
||||
let ping = ser::deserialize::<Ping>(&mut &buf[..])?;
|
||||
adapter.peer_difficulty(addr, ping.total_difficulty);
|
||||
let pong = Pong { total_difficulty: adapter.total_difficulty() };
|
||||
adapter.peer_difficulty(addr, ping.total_difficulty, ping.height);
|
||||
let pong = Pong { total_difficulty: adapter.total_difficulty(), height: adapter.total_height() };
|
||||
let mut body_data = vec![];
|
||||
try!(ser::serialize(&mut body_data, &pong));
|
||||
let mut data = vec![];
|
||||
@@ -157,7 +161,7 @@ fn handle_payload(
|
||||
}
|
||||
Type::Pong => {
|
||||
let pong = ser::deserialize::<Pong>(&mut &buf[..])?;
|
||||
adapter.peer_difficulty(addr, pong.total_difficulty);
|
||||
adapter.peer_difficulty(addr, pong.total_difficulty, pong.height);
|
||||
Ok(None)
|
||||
},
|
||||
Type::Transaction => {
|
||||
|
||||
Reference in New Issue
Block a user