Skip to content

Commit fc2073b

Browse files
committed
GH-1071 Prioritize sending blocks, votes, and everything else over trxs.
1 parent 589d6c2 commit fc2073b

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

plugins/net_plugin/net_plugin.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ namespace eosio {
601601
void clear_write_queue() {
602602
fc::lock_guard g( _mtx );
603603
_write_queue.clear();
604-
_sync_write_queue.clear();
604+
_trx_write_queue.clear();
605605
_write_queue_size = 0;
606606
}
607607

@@ -627,10 +627,10 @@ namespace eosio {
627627
fc::unique_lock g( _mtx );
628628
// if out_queue is not empty then async_write is in progress
629629
bool async_write_in_progress = !_out_queue.empty();
630-
bool ready = ((!_sync_write_queue.empty() || !_write_queue.empty()) && !async_write_in_progress);
630+
bool ready = ((!_trx_write_queue.empty() || !_write_queue.empty()) && !async_write_in_progress);
631631
g.unlock();
632632
if (async_write_in_progress) {
633-
fc_dlog(logger, "Connection - ${id} not ready to send data, async write in progress", ("id", connection_id));
633+
fc_elog(logger, "Connection - ${id} not ready to send data, async write in progress", ("id", connection_id));
634634
}
635635
return ready;
636636
}
@@ -640,8 +640,8 @@ namespace eosio {
640640
std::function<void( boost::system::error_code, std::size_t )> callback,
641641
uint32_t net_message_which ) {
642642
fc::lock_guard g( _mtx );
643-
if( net_message_which == signed_block_which ) {
644-
_sync_write_queue.push_back( {buff, std::move(callback)} );
643+
if( net_message_which == packed_transaction_which ) {
644+
_trx_write_queue.push_back( {buff, std::move(callback)} );
645645
} else {
646646
_write_queue.push_back( {buff, std::move(callback)} );
647647
}
@@ -654,11 +654,11 @@ namespace eosio {
654654

655655
void fill_out_buffer( std::vector<boost::asio::const_buffer>& bufs ) {
656656
fc::lock_guard g( _mtx );
657-
if( !_sync_write_queue.empty() ) { // always send msgs from sync_write_queue first
658-
fill_out_buffer( bufs, _sync_write_queue );
659-
} else { // postpone real_time write_queue if sync queue is not empty
657+
if( !_write_queue.empty() ) { // always send msgs from write_queue first
660658
fill_out_buffer( bufs, _write_queue );
661-
EOS_ASSERT( _write_queue_size == 0, plugin_exception, "write queue size expected to be zero" );
659+
} else {
660+
fill_out_buffer( bufs, _trx_write_queue );
661+
assert(_trx_write_queue.empty() && _write_queue.empty() && _write_queue_size == 0);
662662
}
663663
}
664664

@@ -692,7 +692,7 @@ namespace eosio {
692692
mutable fc::mutex _mtx;
693693
uint32_t _write_queue_size GUARDED_BY(_mtx) {0};
694694
deque<queued_write> _write_queue GUARDED_BY(_mtx);
695-
deque<queued_write> _sync_write_queue GUARDED_BY(_mtx); // sync_write_queue will be sent first
695+
deque<queued_write> _trx_write_queue GUARDED_BY(_mtx); // trx_write_queue will be sent last
696696
deque<queued_write> _out_queue GUARDED_BY(_mtx);
697697

698698
}; // queued_buffer

0 commit comments

Comments
 (0)