Skip to content

Commit

Permalink
feat: Add Stub for AddressBookService
Browse files Browse the repository at this point in the history
Signed-off-by: gsstoykov <[email protected]>
  • Loading branch information
gsstoykov committed Oct 16, 2024
1 parent 8c167d6 commit 8a359c7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions HederaApi.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
set(HAPI_LIBRARY_HASH "46507656510baa279f3ce6d94e0044ef47128ba051467a3748ed55e6cb779db3" CACHE STRING "Use the configured hash to verify the Hedera API protobuf library release")
set(HAPI_LIBRARY_URL "https://github.com/hashgraph/hedera-protobufs-cpp/releases/download/v0.54.0/hapi-library-bb992044.tar.gz" CACHE STRING "Use the configured URL to download the Hedera API protobuf library package")
set(HAPI_LIBRARY_HASH "248299d525ec55425b755565726fc40a9bb9aa8335447f7c07956c9ace1ef64c" CACHE STRING "Use the configured hash to verify the Hedera API protobuf library release")
set(HAPI_LIBRARY_URL "https://github.com/hashgraph/hedera-protobufs-cpp/releases/download/v0.55.0/hapi-library-32c2a4a2.tar.gz" CACHE STRING "Use the configured URL to download the Hedera API protobuf library package")

set(HAPI_LOCAL_LIBRARY_PATH "" CACHE STRING "Overrides the configured HAPI_LIBRARY_URL setting and instead uses the local path to retrieve the artifacts")

Expand Down
6 changes: 6 additions & 0 deletions src/sdk/main/include/impl/Node.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#ifndef HEDERA_SDK_CPP_IMPL_NODE_H_
#define HEDERA_SDK_CPP_IMPL_NODE_H_

#include <proto/address_book_service.grpc.pb.h>
#include <proto/consensus_service.grpc.pb.h>
#include <proto/crypto_service.grpc.pb.h>
#include <proto/file_service.grpc.pb.h>
Expand Down Expand Up @@ -236,6 +237,11 @@ class Node : public BaseNode<Node, AccountId>
*/
std::unique_ptr<proto::UtilService::Stub> mUtilStub = nullptr;

/**
* Pointer to the gRPC stub used to communicate with the address book service living on the remote node.
*/
std::unique_ptr<proto::AddressBookService::Stub> mAddressBookStub = nullptr;

/**
* The AccountId that runs the remote node represented by this Node.
*/
Expand Down
6 changes: 4 additions & 2 deletions src/sdk/main/src/impl/Node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ grpc::Status Node::submitTransaction(proto::TransactionBody::DataCase funcEnum,

switch (funcEnum)
{
case proto::TransactionBody::DataCase::kNodeCreate:
return mAddressBookStub->createNode(&context, transaction, response);
case proto::TransactionBody::DataCase::kConsensusCreateTopic:
return mConsensusStub->createTopic(&context, transaction, response);
case proto::TransactionBody::DataCase::kConsensusDeleteTopic:
Expand Down Expand Up @@ -149,8 +151,6 @@ grpc::Status Node::submitTransaction(proto::TransactionBody::DataCase funcEnum,
return mFileStub->updateFile(&context, transaction, response);
case proto::TransactionBody::DataCase::kFreeze:
return mFreezeStub->freeze(&context, transaction, response);
case proto::TransactionBody::DataCase::kNodeCreate:
return mFreezeStub->freeze(&context, transaction, response);
case proto::TransactionBody::DataCase::kScheduleCreate:
return mScheduleStub->createSchedule(&context, transaction, response);
case proto::TransactionBody::DataCase::kScheduleDelete:
Expand Down Expand Up @@ -288,6 +288,7 @@ void Node::initializeStubs()
if (!mSmartContractStub) mSmartContractStub = proto::SmartContractService::NewStub(getChannel());
if (!mTokenStub) mTokenStub = proto::TokenService::NewStub(getChannel());
if (!mUtilStub) mUtilStub = proto::UtilService::NewStub(getChannel());
if (!mAddressBookStub) mAddressBookStub = proto::AddressBookService::NewStub(getChannel());
// clang-format on
}

Expand All @@ -303,6 +304,7 @@ void Node::closeStubs()
mSmartContractStub = nullptr;
mTokenStub = nullptr;
mUtilStub = nullptr;
mAddressBookStub = nullptr;
}

} // namespace Hedera::internal

0 comments on commit 8a359c7

Please sign in to comment.