Skip to content

Commit 81a676b

Browse files
emwang-jumplidatong
authored andcommitted
repair: modify active peers to work with shred-repair change
1 parent d0228c2 commit 81a676b

File tree

1 file changed

+33
-9
lines changed

1 file changed

+33
-9
lines changed

src/flamenco/repair/fd_repair.c

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -473,11 +473,12 @@ fd_repair_send_requests( fd_repair_t * glob ) {
473473
if( dup && --dup->req_cnt == 0) {
474474
fd_dupdetect_table_remove( glob->dupdetect, &ele->dupkey );
475475
}
476+
FD_LOG_INFO(("removing old request for %lu, %u", ele->dupkey.slot, ele->dupkey.shred_index));
476477
fd_needed_table_remove( glob->needed, &n );
477478
}
478479
glob->oldest_nonce = n;
479480

480-
/* Send requests starting where we left off last time */
481+
/* Send requests starting where we left off last time. i.e. if n < current_nonce, seek forward */
481482
if ( (int)(n - glob->current_nonce) < 0 )
482483
n = glob->current_nonce;
483484
ulong j = 0;
@@ -488,7 +489,7 @@ fd_repair_send_requests( fd_repair_t * glob ) {
488489
if ( NULL == ele )
489490
continue;
490491

491-
if(j == 128U) break;
492+
//if(j == 128U) break;
492493
++j;
493494

494495
/* Track statistics */
@@ -503,6 +504,7 @@ fd_repair_send_requests( fd_repair_t * glob ) {
503504
fd_needed_table_remove( glob->needed, &n );
504505
continue;
505506
}
507+
/* note these requests STAY in table even after being requested */
506508

507509
active->avg_reqs++;
508510
glob->metrics.send_pkt_cnt++;
@@ -519,7 +521,7 @@ fd_repair_send_requests( fd_repair_t * glob ) {
519521
wi->header.nonce = n;
520522
wi->slot = ele->dupkey.slot;
521523
wi->shred_index = ele->dupkey.shred_index;
522-
// FD_LOG_INFO(("[repair]"))
524+
FD_LOG_INFO(( "repair request for %lu, %lu", wi->slot, wi->shred_index ));
523525
break;
524526
}
525527

@@ -533,6 +535,7 @@ fd_repair_send_requests( fd_repair_t * glob ) {
533535
wi->header.nonce = n;
534536
wi->slot = ele->dupkey.slot;
535537
wi->shred_index = ele->dupkey.shred_index;
538+
FD_LOG_INFO(( "repair request for %lu, %lu", wi->slot, wi->shred_index ));
536539
break;
537540
}
538541

@@ -545,6 +548,7 @@ fd_repair_send_requests( fd_repair_t * glob ) {
545548
wi->header.timestamp = glob->now/1000000L;
546549
wi->header.nonce = n;
547550
wi->slot = ele->dupkey.slot;
551+
FD_LOG_INFO(( "repair request for %lu", ele->dupkey.slot));
548552
break;
549553
}
550554
}
@@ -1057,18 +1061,37 @@ fd_repair_create_needed_request( fd_repair_t * glob, int type, ulong slot, uint
10571061
}
10581062

10591063
if (!found_peer) {
1060-
FD_LOG_DEBUG( ( "failed to find a good peer." ) );
1061-
fd_repair_unlock( glob );
1062-
return -1;
1064+
FD_LOG_WARNING( ( "failed to find a good peer." ) );
1065+
FD_LOG_WARNING( ( "SO WE TRYING AGAIN "));
1066+
/* maybe atp we should just... send it. TODO: reevaluate wth testnet */
1067+
1068+
for( ulong i=0UL; i<peer_cnt; i++ ) {
1069+
fd_pubkey_t * id = &glob->actives_sticky[i];
1070+
fd_active_elem_t * peer = fd_active_table_query( glob->actives, id, NULL );
1071+
if( peer ){
1072+
peer->first_request_time = glob->now;
1073+
}
1074+
}
1075+
1076+
// Can guarantee found peers now! lol
1077+
for( ulong i=0UL; i<peer_cnt; i++ ) {
1078+
fd_active_elem_t * peer = actives_sample( glob );
1079+
if(!peer) continue;
1080+
ids[i] = &peer->key;
1081+
}
1082+
//fd_repair_unlock( glob );
1083+
//return -1;
10631084
};
10641085

10651086
fd_dupdetect_key_t dupkey = { .type = (enum fd_needed_elem_type)type, .slot = slot, .shred_index = shred_index };
10661087
fd_dupdetect_elem_t * dupelem = fd_dupdetect_table_query( glob->dupdetect, &dupkey, NULL );
10671088
if( dupelem == NULL ) {
10681089
dupelem = fd_dupdetect_table_insert( glob->dupdetect, &dupkey );
10691090
dupelem->last_send_time = 0L;
1070-
} else if( ( dupelem->last_send_time+(long)100e6 )<glob->now ) {
1091+
} else if( ( dupelem->last_send_time+(long)200e6 )>glob->now ) {
1092+
// if last send time > now - 100ms. then we don't want to add another.
10711093
fd_repair_unlock( glob );
1094+
//FD_LOG_INFO(("deduped request for %lu, %u", slot, shred_index));
10721095
return 0;
10731096
}
10741097

@@ -1081,13 +1104,14 @@ fd_repair_create_needed_request( fd_repair_t * glob, int type, ulong slot, uint
10811104
( *glob->deliver_fail_fun )(ids[0], slot, shred_index, glob->fun_arg, FD_REPAIR_DELIVER_FAIL_REQ_LIMIT_EXCEEDED );
10821105
return -1;
10831106
}
1084-
for( ulong i=0UL; i<peer_cnt; i++ ) {
1107+
for( ulong i=0UL; i<fd_ulong_min( fd_needed_table_key_max( glob->needed ) - fd_needed_table_key_cnt( glob->needed ), peer_cnt ); i++ ) {
10851108
fd_repair_nonce_t key = glob->next_nonce++;
10861109
fd_needed_elem_t * val = fd_needed_table_insert(glob->needed, &key);
10871110
fd_hash_copy(&val->id, ids[i]);
10881111
val->dupkey = dupkey;
10891112
val->when = glob->now;
10901113
}
1114+
FD_LOG_INFO(("added request for %lu, %u", slot, shred_index));
10911115
fd_repair_unlock( glob );
10921116
return 0;
10931117
}
@@ -1163,7 +1187,7 @@ fd_repair_need_highest_window_index( fd_repair_t * glob, ulong slot, uint shred_
11631187

11641188
int
11651189
fd_repair_need_orphan( fd_repair_t * glob, ulong slot ) {
1166-
FD_LOG_NOTICE(( "[%s] need orphan %lu", __func__, slot ));
1190+
FD_LOG_DEBUG( ( "[repair] need orphan %lu", slot ) );
11671191
return fd_repair_create_needed_request( glob, fd_needed_orphan, slot, UINT_MAX );
11681192
}
11691193

0 commit comments

Comments
 (0)