@@ -62,7 +62,8 @@ manager::manager()
62
62
do_cap_( false ),
63
63
do_tx_( true ),
64
64
is_pub_( false ),
65
- cmt_( commitment::e_confirmed )
65
+ cmt_( commitment::e_confirmed ),
66
+ sreq_{ { commitment::e_processed } }
66
67
{
67
68
tconn_.set_sub ( this );
68
69
breq_->set_sub ( this );
@@ -433,6 +434,15 @@ void manager::poll( bool do_wait )
433
434
// get current time
434
435
curr_ts_ = get_now ();
435
436
437
+ // get current slot
438
+ if ( curr_ts_ - slot_ts_ > 200 * PC_NSECS_IN_MSEC ) {
439
+ if ( sreq_->get_is_recv () ) {
440
+ if ( has_status ( PC_PYTH_RPC_CONNECTED ) ) {
441
+ clnt_.send ( sreq_ );
442
+ }
443
+ }
444
+ }
445
+
436
446
// try to (re)connect to tx proxy
437
447
if ( do_tx_ && ( !tconn_.get_is_connect () || tconn_.get_is_err () ) ) {
438
448
tconn_.reconnect ();
@@ -489,8 +499,9 @@ void manager::reconnect_rpc()
489
499
kidx_ = 0 ;
490
500
ctimeout_ = PC_NSECS_IN_SEC;
491
501
pub_ts_ = 0L ;
492
- slot_cnt_ = 0UL ;
493
502
slot_ = 0L ;
503
+ slot_cnt_ = 0UL ;
504
+ slot_ts_ = 0L ;
494
505
num_sub_ = 0 ;
495
506
clnt_.reset ();
496
507
for (;;) {
@@ -634,23 +645,30 @@ void manager::schedule( price_sched *kptr )
634
645
}
635
646
}
636
647
637
- void manager::on_response ( rpc::slot_subscribe *res )
648
+ void manager::on_response ( rpc::get_slot *res )
638
649
{
639
650
// check error
640
651
if ( PC_UNLIKELY ( res->get_is_err () ) ) {
641
- set_err_msg ( " failed to slot_subscribe ["
652
+ set_err_msg ( " failed to get slot ["
642
653
+ res->get_err_msg () + " ]" );
643
654
return ;
644
655
}
645
656
646
657
// ignore slots that go back in time
647
- uint64_t slot = res->get_slot ();
658
+ uint64_t slot = res->get_current_slot ();
648
659
int64_t ts = res->get_recv_time ();
649
660
if ( slot <= slot_ ) {
650
661
return ;
651
662
}
652
663
slot_ = slot;
653
- PC_LOG_DBG ( " receive slot" ).add ( " slot" , slot_ ).end ();
664
+ slot_ts_ = ts;
665
+
666
+ int64_t ack_ts = res->get_recv_time () - res->get_sent_time ();
667
+
668
+ PC_LOG_DBG ( " received get_slot" )
669
+ .add ( " slot" , slot_ )
670
+ .add ( " rount_trip_time(ms)" , 1e-6 *ack_ts )
671
+ .end ();
654
672
655
673
// submit block hash every N slots
656
674
if ( slot_cnt_++ % PC_BLOCKHASH_TIMEOUT == 0 ) {
0 commit comments