@@ -62,7 +62,8 @@ manager::manager()
6262 do_cap_( false ),
6363 do_tx_( true ),
6464 is_pub_( false ),
65- cmt_( commitment::e_confirmed )
65+ cmt_( commitment::e_confirmed ),
66+ sreq_{ { commitment::e_processed } }
6667{
6768 tconn_.set_sub ( this );
6869 breq_->set_sub ( this );
@@ -433,6 +434,15 @@ void manager::poll( bool do_wait )
433434 // get current time
434435 curr_ts_ = get_now ();
435436
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+
436446 // try to (re)connect to tx proxy
437447 if ( do_tx_ && ( !tconn_.get_is_connect () || tconn_.get_is_err () ) ) {
438448 tconn_.reconnect ();
@@ -489,8 +499,9 @@ void manager::reconnect_rpc()
489499 kidx_ = 0 ;
490500 ctimeout_ = PC_NSECS_IN_SEC;
491501 pub_ts_ = 0L ;
492- slot_cnt_ = 0UL ;
493502 slot_ = 0L ;
503+ slot_cnt_ = 0UL ;
504+ slot_ts_ = 0L ;
494505 num_sub_ = 0 ;
495506 clnt_.reset ();
496507 for (;;) {
@@ -634,23 +645,30 @@ void manager::schedule( price_sched *kptr )
634645 }
635646}
636647
637- void manager::on_response ( rpc::slot_subscribe *res )
648+ void manager::on_response ( rpc::get_slot *res )
638649{
639650 // check error
640651 if ( PC_UNLIKELY ( res->get_is_err () ) ) {
641- set_err_msg ( " failed to slot_subscribe ["
652+ set_err_msg ( " failed to get slot ["
642653 + res->get_err_msg () + " ]" );
643654 return ;
644655 }
645656
646657 // ignore slots that go back in time
647- uint64_t slot = res->get_slot ();
658+ uint64_t slot = res->get_current_slot ();
648659 int64_t ts = res->get_recv_time ();
649660 if ( slot <= slot_ ) {
650661 return ;
651662 }
652663 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 ();
654672
655673 // submit block hash every N slots
656674 if ( slot_cnt_++ % PC_BLOCKHASH_TIMEOUT == 0 ) {
0 commit comments