From a9f53cce98b9b75db2de9c2fbae163ef44eed6e3 Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Mon, 27 Jan 2014 20:10:32 -0200 Subject: [PATCH] trying to reduce the occurrences of "INCOMING ERROR: height > getBestHeight" --- libtorrent/src/kademlia/node.cpp | 7 ++++++- src/twister.cpp | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libtorrent/src/kademlia/node.cpp b/libtorrent/src/kademlia/node.cpp index 84d0fb06..37e20ebb 100644 --- a/libtorrent/src/kademlia/node.cpp +++ b/libtorrent/src/kademlia/node.cpp @@ -520,6 +520,11 @@ bool node_impl::refresh_storage() { // FIXME: optimize to avoid bdecode (store seq separated, etc) int ret = lazy_bdecode(item.p.data(), item.p.data() + item.p.size(), p, err, &pos, 10, 500); + int height = p.dict_find_int_value("height"); + if( height > getBestHeight() ) { + continue; // how? + } + const lazy_entry *target = p.dict_find_dict("target"); std::string username = target->dict_find_string_value("n"); std::string resource = target->dict_find_string_value("r"); @@ -1263,7 +1268,7 @@ void node_impl::incoming_request(msg const& m, entry& e) return; } - if (msg_keys[mk_height]->int_value() > getBestHeight() && getBestHeight() > 0) { + if (msg_keys[mk_height]->int_value() > getBestHeight()+1 && getBestHeight() > 0) { incoming_error(e, "height > getBestHeight"); return; } diff --git a/src/twister.cpp b/src/twister.cpp index 32a3b785..c8b57e50 100644 --- a/src/twister.cpp +++ b/src/twister.cpp @@ -882,7 +882,7 @@ bool acceptSignedPost(char const *data, int data_size, std::string username, int } else if( !validatePostNumberForUser(username, k) ) { sprintf(errbuf,"too much posts from user '%s' rejecting post", username.c_str()); - } else if( height < 0 || (height > getBestHeight() && getBestHeight() > 0) ) { + } else if( height < 0 || (height > getBestHeight()+1 && getBestHeight() > 0) ) { sprintf(errbuf,"post from future not accepted (height: %d > %d)", height, getBestHeight()); } else if( msgUtf8Chars < 0 ) {