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:
Simon B
2017-12-13 22:52:21 +01:00
committed by Ignotus Peverell
parent bffd955c26
commit 17d5898677
15 changed files with 126 additions and 73 deletions
+10 -3
View File
@@ -43,6 +43,10 @@ impl NetAdapter for NetToChainAdapter {
self.chain.total_difficulty()
}
fn total_height(&self) -> u64 {
self.chain.head().unwrap().height
}
fn transaction_received(&self, tx: core::Transaction) {
let source = pool::TxSource {
debug_name: "p2p".to_string(),
@@ -247,16 +251,19 @@ impl NetAdapter for NetToChainAdapter {
}
}
fn peer_difficulty(&self, addr: SocketAddr, diff: Difficulty) {
fn peer_difficulty(&self, addr: SocketAddr, diff: Difficulty, height: u64) {
debug!(
LOGGER,
"peer total_diff (ping/pong): {}, {} vs us {}",
"peer total_diff @ height (ping/pong): {}: {} @ {} \
vs us: {} @ {}",
addr,
diff,
height,
self.total_difficulty(),
self.total_height()
);
if diff.into_num() > 0 {
if self.p2p_server.is_initialized() {
if let Some(peer) = self.p2p_server.borrow().get_peer(&addr) {
let mut peer = peer.write().unwrap();
peer.info.total_difficulty = diff;