@@ -81,13 +81,17 @@ Task<void> TxCall::operator()(const EthereumBackEnd& backend) {
81
81
82
82
grpc::Status status{grpc::Status::OK};
83
83
try {
84
+ // Assign a monotonically increasing unique ID to remote transaction
85
+ const auto tx_id = ++next_tx_id_;
86
+
84
87
// Create a new read-only transaction.
85
88
read_only_txn_ = db::ROTxnManaged{*chaindata_env};
86
- SILK_DEBUG << " TxCall peer: " << peer () << " started tx: " << read_only_txn_->id ();
89
+ SILK_DEBUG << " TxCall peer: " << peer () << " started tx: " << tx_id << " view: " << read_only_txn_->id ();
87
90
88
- // Send an unsolicited message containing the transaction ID.
91
+ // Send an unsolicited message containing the transaction ID and view ID (i.e. MDBX txn ID)
89
92
remote::Pair tx_id_pair;
90
- tx_id_pair.set_tx_id (read_only_txn_->id ());
93
+ tx_id_pair.set_tx_id (tx_id);
94
+ tx_id_pair.set_view_id (read_only_txn_->id ());
91
95
if (!co_await agrpc::write (responder_, tx_id_pair)) {
92
96
SILK_WARN << " Tx closed by peer: " << server_context_.peer () << " error: write failed" ;
93
97
co_await agrpc::finish (responder_, grpc::Status::OK);
@@ -107,6 +111,7 @@ Task<void> TxCall::operator()(const EthereumBackEnd& backend) {
107
111
remote::Cursor request;
108
112
read_stream.initiate (agrpc::read, responder_, request);
109
113
114
+ // NOLINTNEXTLINE(cppcoreguidelines-avoid-capturing-lambda-coroutines)
110
115
const auto read = [&]() -> Task<void > {
111
116
try {
112
117
while (co_await read_stream.next ()) {
@@ -135,10 +140,12 @@ Task<void> TxCall::operator()(const EthereumBackEnd& backend) {
135
140
status = grpc::Status{grpc::StatusCode::INTERNAL, exc.what ()};
136
141
}
137
142
};
143
+ // NOLINTNEXTLINE(cppcoreguidelines-avoid-capturing-lambda-coroutines)
138
144
const auto write = [&]() -> Task<void > {
139
145
while (co_await write_stream.next ()) {
140
146
}
141
147
};
148
+ // NOLINTNEXTLINE(cppcoreguidelines-avoid-capturing-lambda-coroutines)
142
149
const auto max_idle_timer = [&]() -> Task<void > {
143
150
while (true ) {
144
151
const auto [ec] = co_await max_idle_alarm.async_wait (as_tuple (use_awaitable));
@@ -150,6 +157,7 @@ Task<void> TxCall::operator()(const EthereumBackEnd& backend) {
150
157
}
151
158
}
152
159
};
160
+ // NOLINTNEXTLINE(cppcoreguidelines-avoid-capturing-lambda-coroutines)
153
161
const auto max_ttl_timer = [&]() -> Task<void > {
154
162
while (true ) {
155
163
const auto [ec] = co_await max_ttl_alarm.async_wait (as_tuple (use_awaitable));
@@ -404,7 +412,7 @@ bool TxCall::restore_cursors(std::vector<CursorPosition>& positions) {
404
412
}
405
413
} else {
406
414
/* single-value table */
407
- const auto result = (key.length () == 0 ) ? cursor->to_first (/* throw_notfound=*/ false ) : cursor->lower_bound (key, /* throw_notfound=*/ false );
415
+ const auto result = (key.empty () ) ? cursor->to_first (/* throw_notfound=*/ false ) : cursor->lower_bound (key, /* throw_notfound=*/ false );
408
416
SILK_DEBUG << " Tx restore cursor " << cursor_id << " for: " << bucket_name << " result: " << db::detail::dump_mdbx_result (result);
409
417
if (!result) {
410
418
return false ;
@@ -447,7 +455,7 @@ void TxCall::handle_seek(const remote::Cursor* request, db::ROCursorDupSort& cur
447
455
SILK_TRACE << " TxCall::handle_seek " << this << " START" ;
448
456
mdbx::slice key{request->k ()};
449
457
450
- const auto result = (key.length () == 0 ) ? cursor.to_first (/* throw_notfound=*/ false ) : cursor.lower_bound (key, /* throw_notfound=*/ false );
458
+ const auto result = (key.empty () ) ? cursor.to_first (/* throw_notfound=*/ false ) : cursor.lower_bound (key, /* throw_notfound=*/ false );
451
459
SILK_DEBUG << " Tx SEEK result: " << db::detail::dump_mdbx_result (result);
452
460
453
461
if (result) {
@@ -716,4 +724,54 @@ Task<void> StateChangesCall::operator()(const EthereumBackEnd& backend) {
716
724
co_return ;
717
725
}
718
726
727
+ Task<void > SnapshotsCall::operator ()(const EthereumBackEnd& /* backend*/ ) {
728
+ SILK_TRACE << " SnapshotsCall START" ;
729
+ remote::SnapshotsReply response;
730
+ // TODO(canepat) implement properly
731
+ co_await agrpc::finish (responder_, response, grpc::Status::OK);
732
+ SILK_TRACE << " SnapshotsCall END #blocks_files: " << response.blocks_files_size () << " #history_files: " << response.history_files_size ();
733
+ }
734
+
735
+ Task<void > HistoryGetCall::operator ()(const EthereumBackEnd& /* backend*/ ) {
736
+ SILK_TRACE << " HistoryGetCall START" ;
737
+ remote::HistoryGetReply response;
738
+ // TODO(canepat) implement properly
739
+ co_await agrpc::finish (responder_, response, grpc::Status::OK);
740
+ SILK_TRACE << " HistoryGetCall END ok: " << response.ok () << " value: " << response.v ();
741
+ }
742
+
743
+ Task<void > DomainGetCall::operator ()(const EthereumBackEnd& /* backend*/ ) {
744
+ SILK_TRACE << " DomainGetCall START" ;
745
+ remote::DomainGetReply response;
746
+ // TODO(canepat) implement properly
747
+ co_await agrpc::finish (responder_, response, grpc::Status::OK);
748
+ SILK_TRACE << " DomainGetCall END ok: " << response.ok () << " value: " << response.v ();
749
+ }
750
+
751
+ Task<void > IndexRangeCall::operator ()(const EthereumBackEnd& /* backend*/ ) {
752
+ SILK_TRACE << " IndexRangeCall START" ;
753
+ remote::IndexRangeReply response;
754
+ // TODO(canepat) implement properly
755
+ co_await agrpc::finish (responder_, response, grpc::Status::OK);
756
+ SILK_TRACE << " IndexRangeCall END #timestamps: " << response.timestamps_size () << " next_page_token: " << response.next_page_token ();
757
+ }
758
+
759
+ Task<void > HistoryRangeCall::operator ()(const EthereumBackEnd& /* backend*/ ) {
760
+ SILK_TRACE << " HistoryRangeCall START" ;
761
+ remote::Pairs response;
762
+ // TODO(canepat) implement properly
763
+ co_await agrpc::finish (responder_, response, grpc::Status::OK);
764
+ SILK_TRACE << " HistoryRangeCall END #keys: " << response.keys_size () << " #values: " << response.values_size ()
765
+ << " next_page_token: " << response.next_page_token ();
766
+ }
767
+
768
+ Task<void > DomainRangeCall::operator ()(const EthereumBackEnd& /* backend*/ ) {
769
+ SILK_TRACE << " DomainRangeCall START" ;
770
+ remote::Pairs response;
771
+ // TODO(canepat) implement properly
772
+ co_await agrpc::finish (responder_, response, grpc::Status::OK);
773
+ SILK_TRACE << " DomainRangeCall END #keys: " << response.keys_size () << " #values: " << response.values_size ()
774
+ << " next_page_token: " << response.next_page_token ();
775
+ }
776
+
719
777
} // namespace silkworm::rpc
0 commit comments