mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-22 20:44:56 +00:00
delay libtorrent initialization until we have valid blocks
This commit is contained in:
parent
80f23d56e8
commit
a4695ba9e1
@ -1249,7 +1249,7 @@ void node_impl::incoming_request(msg const& m, entry& e)
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg_keys[mk_height]->int_value() > getBestHeight() && getBestHeight()) {
|
||||
if (msg_keys[mk_height]->int_value() > getBestHeight() && getBestHeight() > 0) {
|
||||
incoming_error(e, "height > getBestHeight");
|
||||
return;
|
||||
}
|
||||
|
@ -727,7 +727,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
break;
|
||||
}
|
||||
|
||||
if( mapBlockIndex.size() > 1000 && nBestHeight == 0 ) {
|
||||
if( mapBlockIndex.size() > 1000 && nBestHeight <= 0 ) {
|
||||
strLoadError = _("mapBlockIndex detected but nBestHeight still zero, trying to repair (reindex)");
|
||||
break;
|
||||
}
|
||||
|
@ -182,6 +182,11 @@ void ThreadWaitExtIP()
|
||||
MilliSleep(500);
|
||||
}
|
||||
|
||||
// delay libtorrent initialization until we have valid blocks
|
||||
while( getBestHeight() <= 0 ) {
|
||||
MilliSleep(500);
|
||||
}
|
||||
|
||||
error_code ec;
|
||||
int listen_port = GetListenPort() + LIBTORRENT_PORT_OFFSET;
|
||||
std::string bind_to_interface = "";
|
||||
@ -268,6 +273,10 @@ void ThreadMaintainDHTNodes()
|
||||
{
|
||||
RenameThread("maintain-dht-nodes");
|
||||
|
||||
while(!ses) {
|
||||
MilliSleep(200);
|
||||
}
|
||||
|
||||
while(1) {
|
||||
MilliSleep(5000);
|
||||
|
||||
@ -745,7 +754,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()) ) {
|
||||
} else if( height < 0 || (height > getBestHeight() && getBestHeight() > 0) ) {
|
||||
sprintf(errbuf,"post from future not accepted (height: %d > %d)",
|
||||
height, getBestHeight());
|
||||
} else if( msg.size() && msg.size() > 140 ) {
|
||||
@ -808,7 +817,7 @@ bool validatePostNumberForUser(std::string const &username, int k)
|
||||
|
||||
if( k < 0 )
|
||||
return false;
|
||||
if( getBestHeight() && k > 2*(getBestHeight() - pblockindex->nHeight) + 20)
|
||||
if( getBestHeight() > 0 && k > 2*(getBestHeight() - pblockindex->nHeight) + 20)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user