Skip to content

Commit f353b2d

Browse files
committed
Publish prices to both primary and secondary networks if possible.
1 parent 472f0e6 commit f353b2d

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

pc/user.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,19 +198,31 @@ void user::parse_upd_price( uint32_t tok, uint32_t itok )
198198
pub_key pkey;
199199
pkey.init_from_text( jp_.get_str( ntok ) );
200200
price *sptr = sptr_->get_price( pkey );
201-
if ( PC_UNLIKELY( !sptr ) ) { add_unknown_symbol(itok); return; }
201+
price *sptr_secondary = nullptr;
202+
if ( sptr_->has_secondary() ) {
203+
sptr_secondary = sptr_->get_secondary()->get_price( pkey );
204+
}
205+
206+
// Bail if we cannot find the price in either manager.
207+
if ( PC_UNLIKELY( !sptr && !sptr_secondary ) ) { add_unknown_symbol(itok); return; }
208+
202209
if ( 0 == (ntok = jp_.find_val( ptok, "price" ) ) ) break;
203210
int64_t price = jp_.get_int( ntok );
204211
if ( 0 == (ntok = jp_.find_val( ptok, "conf" ) ) ) break;
205212
uint64_t conf = jp_.get_uint( ntok );
206213
if ( 0 == (ntok = jp_.find_val( ptok, "status" ) ) ) break;
207214
symbol_status stype = str_to_symbol_status( jp_.get_str( ntok ) );
208215

209-
// Add the updated price to the pending updates
210-
sptr->update_no_send( price, conf, stype, false );
211-
212-
// pass the updated price to manager
213-
sptr_->add_dirty_price(sptr);
216+
// Add the price to both the managers pending updates, so that it will
217+
// be published to both networks if possible.
218+
if ( sptr ) {
219+
sptr->update_no_send( price, conf, stype, false );
220+
sptr_->add_dirty_price( sptr );
221+
}
222+
if ( sptr_secondary ) {
223+
sptr_secondary->update_no_send( price, conf, stype, false );
224+
sptr_->get_secondary()->add_dirty_price( sptr_secondary );
225+
}
214226

215227
// Send the result back
216228
add_header();

0 commit comments

Comments
 (0)