@ -1339,6 +1339,7 @@ Value dhtget(const Array& params, bool fHelp)
time_duration timeToWait = seconds ( 10 ) ;
time_duration timeToWait = seconds ( 10 ) ;
time_duration timeToWaitMulti = milliseconds ( 100 ) ;
time_duration timeToWaitMulti = milliseconds ( 100 ) ;
int minMultiReplies = 3 ;
int minMultiReplies = 3 ;
int lastSeq = - 1 ;
if ( params . size ( ) > 3 )
if ( params . size ( ) > 3 )
timeToWait = milliseconds ( params [ 3 ] . get_int ( ) ) ;
timeToWait = milliseconds ( params [ 3 ] . get_int ( ) ) ;
@ -1372,12 +1373,17 @@ Value dhtget(const Array& params, bool fHelp)
libtorrent : : entry & e = * it ;
libtorrent : : entry & e = * it ;
hexcapeDht ( e ) ;
hexcapeDht ( e ) ;
string sig_p = safeGetEntryString ( e , " sig_p " ) ;
string sig_p = safeGetEntryString ( e , " sig_p " ) ;
if ( ! sig_p . length ( ) ) {
int seq = ( multi ) ? 0 : safeGetEntryInt ( safeGetEntryDict ( e , " p " ) , " seq " ) ;
bool acceptEntry = ( multi ) ? ( ! sig_p . length ( ) | | ! uniqueSigPs . count ( sig_p ) ) :
( seq > lastSeq ) ;
if ( acceptEntry ) {
if ( ! multi ) {
ret . clear ( ) ;
}
ret . push_back ( entryToJson ( e ) ) ;
ret . push_back ( entryToJson ( e ) ) ;
} else {
lastSeq = seq ;
if ( ! uniqueSigPs . count ( sig_p ) ) {
if ( sig_p . length ( ) ) {
uniqueSigPs . insert ( sig_p ) ;
uniqueSigPs . insert ( sig_p ) ;
ret . push_back ( entryToJson ( e ) ) ;
}
}
}
}
}
}
@ -1387,13 +1393,9 @@ Value dhtget(const Array& params, bool fHelp)
break ;
break ;
}
}
if ( multi ) {
if ( repliesReceived + + < minMultiReplies ) {
if ( repliesReceived + + < minMultiReplies & & uniqueSigPs . size ( ) ) {
timeToWait = timeToWaitMulti ;
timeToWait = timeToWaitMulti ;
//printf("dhtget: wait again %d\n", repliesReceived);
//printf("dhtget: wait again repliesReceived=%d lastSeq=%d\n", repliesReceived, lastSeq);
} else {
break ;
}
} else {
} else {
break ;
break ;
}
}