Skip to content

Commit 6aadd6f

Browse files
authored
Fix inaccurate num_sent metric for last element in batch (#163)
* Fix inaccurate num_sent metric for last element in batch * Add comments to price::send * Update comment
1 parent c3f7bca commit 6aadd6f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pc/request.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,7 @@ bool price::send( price *prices[], const unsigned n )
729729

730730
manager *mgr1 = nullptr;
731731

732+
// Build an upd_price rpc request for every price
732733
for ( unsigned i = 0, j = 0; i < n; ++i ) {
733734
price *const p = prices[ i ];
734735
if ( PC_UNLIKELY( ! p->init_ && ! p->init_publish() ) ) {
@@ -772,6 +773,8 @@ bool price::send( price *prices[], const unsigned n )
772773
p->preq_->set_block_hash( mgr->get_recent_block_hash() );
773774
upds_.emplace_back( p->preq_ );
774775

776+
// If the batch is full, or we have reached the end, send the upd_price requests in upds_.
777+
// These correspond to the valid prices[j..i], inclusive.
775778
if (
776779
upds_.size() >= mgr->get_max_batch_size()
777780
|| ( upds_.size() && ( i + 1 ) == n )
@@ -823,7 +826,7 @@ bool price::send( price *prices[], const unsigned n )
823826
p1->inc_sent();
824827
}
825828

826-
j = i;
829+
j = i + 1;
827830
upds_.clear();
828831
}
829832
}

0 commit comments

Comments
 (0)