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 )
1021
1021
1022
1022
void manager::add_dirty_price (price* sptr)
1023
1023
{
1024
+ // Skip this update if we have already attempted to update this price in the current slot.
1025
+ if ( sptr->get_last_attempted_update_slot () == get_slot () ) {
1026
+ return ;
1027
+ }
1028
+
1024
1029
if ( std::find (pending_upds_.begin (), pending_upds_.end (), sptr) == pending_upds_.end () ) {
1025
1030
pending_upds_.emplace_back ( sptr );
1026
1031
}
Original file line number Diff line number Diff line change @@ -458,7 +458,8 @@ price::price( const pub_key& acc, product *prod )
458
458
prod_( prod ),
459
459
sched_( this ),
460
460
pinit_( this ),
461
- pptr_(nullptr )
461
+ pptr_(nullptr ),
462
+ last_attempted_update_slot_( 0UL )
462
463
{
463
464
areq_->set_account ( &apub_ );
464
465
preq_->set_account ( &apub_ );
@@ -558,6 +559,16 @@ uint64_t price::get_twac() const
558
559
return static_cast < uint64_t >( pptr_->twac_ .val_ );
559
560
}
560
561
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
+
561
572
uint64_t price::get_prev_slot () const
562
573
{
563
574
return pptr_->prev_slot_ ;
@@ -738,6 +749,7 @@ bool price::send( price *prices[], const unsigned n )
738
749
for ( unsigned i = 0 , j = 0 ; i < n; ++i ) {
739
750
price *const p = prices[ i ];
740
751
manager *const mgr = p->get_manager ();
752
+ p->set_last_attempted_update_slot ( mgr->get_slot () );
741
753
if ( PC_UNLIKELY ( ! p->init_ && ! p->init_publish () ) ) {
742
754
PC_LOG_ERR ( " failed to initialize publisher" )
743
755
.add ( " secondary" , mgr->get_is_secondary () )
Original file line number Diff line number Diff line change @@ -265,6 +265,10 @@ namespace pc
265
265
// ready to publish (i.e. not waiting for confirmation)
266
266
bool get_is_ready_publish () const ;
267
267
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
+
268
272
// submit new price update and update aggregate
269
273
// will fail with false if in error (check get_is_err() )
270
274
// or because symbol is not ready to publish (get_is_ready_publish())
@@ -359,6 +363,7 @@ namespace pc
359
363
rpc::upd_price preq_[1 ];
360
364
pc_price_t *pptr_;
361
365
txid_vec_t tvec_;
366
+ uint64_t last_attempted_update_slot_;
362
367
};
363
368
364
369
template <class T >
You can’t perform that action at this time.
0 commit comments