Skip to content
This repository was archived by the owner on Jan 9, 2024. It is now read-only.

Commit 0edf22a

Browse files
authored
Templatize Asio awaitables for gRPC interfaces (#93)
1 parent 7dcd3d1 commit 0edf22a

27 files changed

+370
-610
lines changed

cmd/ethbackend_coroutines.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ int main(int argc, char* argv[]) {
6565

6666
// TODO(canepat): handle also secure channel for remote
6767
silkrpc::ChannelFactory create_channel = [&]() {
68-
return ::grpc::CreateChannel(target, ::grpc::InsecureChannelCredentials());
68+
return grpc::CreateChannel(target, grpc::InsecureChannelCredentials());
6969
};
7070
// TODO(canepat): handle also local (shared-memory) database
7171
silkrpc::ContextPool context_pool{1, create_channel};

cmd/kv_seek_async_coroutines.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ int main(int argc, char* argv[]) {
9696

9797
// TODO(canepat): handle also secure channel for remote
9898
silkrpc::ChannelFactory create_channel = [&]() {
99-
return ::grpc::CreateChannel(target, ::grpc::InsecureChannelCredentials());
99+
return grpc::CreateChannel(target, grpc::InsecureChannelCredentials());
100100
};
101101
// TODO(canepat): handle also local (shared-memory) database
102102
silkrpc::ContextPool context_pool{1, create_channel};

examples/get_latest_block.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ int main(int argc, char* argv[]) {
8585

8686
// TODO(canepat): handle also secure channel for remote
8787
silkrpc::ChannelFactory create_channel = [&]() {
88-
return ::grpc::CreateChannel(target, ::grpc::InsecureChannelCredentials());
88+
return grpc::CreateChannel(target, grpc::InsecureChannelCredentials());
8989
};
9090
// TODO(canepat): handle also local (shared-memory) database
9191
silkrpc::ContextPool context_pool{1, create_channel};

silkrpc/context_pool.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ ContextPool::ContextPool(std::size_t pool_size, ChannelFactory create_channel) :
4444
for (std::size_t i{0}; i < pool_size; ++i) {
4545
auto io_context = std::make_shared<asio::io_context>();
4646
auto grpc_channel = create_channel();
47-
auto grpc_queue = std::make_unique<::grpc::CompletionQueue>();
48-
auto grpc_runner = std::make_unique<grpc::CompletionRunner>(*grpc_queue, *io_context);
47+
auto grpc_queue = std::make_unique<grpc::CompletionQueue>();
48+
auto grpc_runner = std::make_unique<CompletionRunner>(*grpc_queue, *io_context);
4949
auto database = std::make_unique<ethdb::kv::RemoteDatabase>(*io_context, grpc_channel, grpc_queue.get()); // TODO(canepat): move elsewhere
5050
auto backend = std::make_unique<ethbackend::BackEnd>(*io_context, grpc_channel, grpc_queue.get()); // TODO(canepat): move elsewhere
5151
contexts_.push_back({io_context, std::move(grpc_queue), std::move(grpc_runner), std::move(database), std::move(backend)});

silkrpc/context_pool.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ namespace silkrpc {
3535

3636
struct Context {
3737
std::shared_ptr<asio::io_context> io_context;
38-
std::unique_ptr<::grpc::CompletionQueue> grpc_queue;
39-
std::unique_ptr<grpc::CompletionRunner> grpc_runner;
38+
std::unique_ptr<grpc::CompletionQueue> grpc_queue;
39+
std::unique_ptr<CompletionRunner> grpc_runner;
4040
std::unique_ptr<ethdb::Database> database;
4141
std::unique_ptr<ethbackend::BackEnd> backend;
4242
};
4343

4444
std::ostream& operator<<(std::ostream& out, const Context& c);
4545

46-
using ChannelFactory = std::function<std::shared_ptr<::grpc::Channel>()>;
46+
using ChannelFactory = std::function<std::shared_ptr<grpc::Channel>()>;
4747

4848
class ContextPool {
4949
public:
@@ -63,7 +63,7 @@ class ContextPool {
6363
private:
6464
// The pool of contexts
6565
std::vector<Context> contexts_;
66-
std::vector<::grpc::CompletionQueue> queues_;
66+
std::vector<grpc::CompletionQueue> queues_;
6767

6868
// The work-tracking executors that keep the io_contexts running
6969
std::list<asio::execution::any_executor<>> work_;

silkrpc/ethbackend/async_etherbase.hpp

Lines changed: 0 additions & 75 deletions
This file was deleted.

silkrpc/ethbackend/async_protocol_version.hpp

Lines changed: 0 additions & 75 deletions
This file was deleted.

silkrpc/ethbackend/awaitables.hpp

Lines changed: 0 additions & 151 deletions
This file was deleted.

0 commit comments

Comments
 (0)