File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -1021,6 +1021,11 @@ price *manager::get_price( const pub_key& acc )
10211021
10221022void manager::add_dirty_price (price* sptr)
10231023{
1024+ // Skip this update if we have already attempted an update in this slot.
1025+ if ( sptr->get_last_attempted_update_slot () == get_slot () ) {
1026+ return ;
1027+ }
1028+
10241029 if ( std::find (pending_upds_.begin (), pending_upds_.end (), sptr) == pending_upds_.end () ) {
10251030 pending_upds_.emplace_back ( sptr );
10261031 }
Original file line number Diff line number Diff line change @@ -458,7 +458,8 @@ price::price( const pub_key& acc, product *prod )
458458 prod_( prod ),
459459 sched_( this ),
460460 pinit_( this ),
461- pptr_(nullptr )
461+ pptr_(nullptr ),
462+ last_attempted_update_slot_( 0UL )
462463{
463464 areq_->set_account ( &apub_ );
464465 preq_->set_account ( &apub_ );
@@ -558,6 +559,16 @@ uint64_t price::get_twac() const
558559 return static_cast < uint64_t >( pptr_->twac_ .val_ );
559560}
560561
562+ uint64_t price::get_last_attempted_update_slot () const
563+ {
564+ return last_attempted_update_slot_;
565+ }
566+
567+ void price::set_last_attempted_update_slot ( uint64_t slot )
568+ {
569+ last_attempted_update_slot_ = slot;
570+ }
571+
561572uint64_t price::get_prev_slot () const
562573{
563574 return pptr_->prev_slot_ ;
@@ -738,6 +749,7 @@ bool price::send( price *prices[], const unsigned n )
738749 for ( unsigned i = 0 , j = 0 ; i < n; ++i ) {
739750 price *const p = prices[ i ];
740751 manager *const mgr = p->get_manager ();
752+ p->set_last_attempted_update_slot ( mgr->get_slot () );
741753 if ( PC_UNLIKELY ( ! p->init_ && ! p->init_publish () ) ) {
742754 PC_LOG_ERR ( " failed to initialize publisher" )
743755 .add ( " secondary" , mgr->get_is_secondary () )
Original file line number Diff line number Diff line change @@ -265,6 +265,10 @@ namespace pc
265265 // ready to publish (i.e. not waiting for confirmation)
266266 bool get_is_ready_publish () const ;
267267
268+ // the slot when a price update was last attempted
269+ uint64_t get_last_attempted_update_slot () const ;
270+ void set_last_attempted_update_slot ( uint64_t );
271+
268272 // submit new price update and update aggregate
269273 // will fail with false if in error (check get_is_err() )
270274 // or because symbol is not ready to publish (get_is_ready_publish())
@@ -359,6 +363,7 @@ namespace pc
359363 rpc::upd_price preq_[1 ];
360364 pc_price_t *pptr_;
361365 txid_vec_t tvec_;
366+ uint64_t last_attempted_update_slot_;
362367 };
363368
364369 template <class T >
You can’t perform that action at this time.
0 commit comments