Browse Source

trying to reduce the occurrences of "INCOMING ERROR: height > getBestHeight"

miguelfreitas
Miguel Freitas 11 years ago
parent
commit
a9f53cce98
  1. 7
      libtorrent/src/kademlia/node.cpp
  2. 2
      src/twister.cpp

7
libtorrent/src/kademlia/node.cpp

@ -520,6 +520,11 @@ bool node_impl::refresh_storage() {
// FIXME: optimize to avoid bdecode (store seq separated, etc) // 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 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"); const lazy_entry *target = p.dict_find_dict("target");
std::string username = target->dict_find_string_value("n"); std::string username = target->dict_find_string_value("n");
std::string resource = target->dict_find_string_value("r"); std::string resource = target->dict_find_string_value("r");
@ -1263,7 +1268,7 @@ void node_impl::incoming_request(msg const& m, entry& e)
return; 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"); incoming_error(e, "height > getBestHeight");
return; return;
} }

2
src/twister.cpp

@ -882,7 +882,7 @@ bool acceptSignedPost(char const *data, int data_size, std::string username, int
} else if( !validatePostNumberForUser(username, k) ) { } else if( !validatePostNumberForUser(username, k) ) {
sprintf(errbuf,"too much posts from user '%s' rejecting post", sprintf(errbuf,"too much posts from user '%s' rejecting post",
username.c_str()); 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)", sprintf(errbuf,"post from future not accepted (height: %d > %d)",
height, getBestHeight()); height, getBestHeight());
} else if( msgUtf8Chars < 0 ) { } else if( msgUtf8Chars < 0 ) {

Loading…
Cancel
Save