Skip to content

Commit 928602e

Browse files
authored
fix node info broadcast (#128)
* install python to wedpr-mpc * fix node info broadcast
1 parent c5365e7 commit 928602e

File tree

5 files changed

+12
-3
lines changed

5 files changed

+12
-3
lines changed

cpp/wedpr-protocol/protobuf/src/NodeInfoImpl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ void NodeInfoImpl::encode(bcos::bytes& data) const
3232
void NodeInfoImpl::encodeFields() const
3333
{
3434
bcos::ReadGuard l(x_components);
35+
m_rawNodeInfo->clear_components();
3536
// set the components
3637
for (auto const& component : m_components)
3738
{

cpp/wedpr-transport/ppc-gateway/ppc-gateway/gateway/router/GatewayNodeInfoImpl.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ bool GatewayNodeInfoImpl::tryAddNodeInfo(INodeInfo::Ptr const& info, bool& updat
117117
GATEWAY_LOG(INFO) << LOG_DESC("tryAddNodeInfo, update the components, updated nodeInfo")
118118
<< printNodeInfo(existedNodeInfo);
119119
}
120+
// the existed node re-encode
121+
if (updated)
122+
{
123+
auto nodeInfo = std::dynamic_pointer_cast<NodeInfoImpl>(existedNodeInfo);
124+
nodeInfo->encodeFields();
125+
}
120126
return false;
121127
}
122128
{

cpp/wedpr-transport/ppc-gateway/ppc-gateway/gateway/router/LocalRouter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ using namespace ppc::gateway;
2929
bool LocalRouter::registerNodeInfo(ppc::protocol::INodeInfo::Ptr nodeInfo,
3030
std::function<void()> onUnHealthHandler, bool removeHandlerOnUnhealth)
3131
{
32-
LOCAL_ROUTER_LOG(DEBUG) << LOG_DESC("registerNodeInfo") << printNodeInfo(nodeInfo);
3332
bool updated = false;
3433
auto ret = m_routerInfo->tryAddNodeInfo(nodeInfo, updated);
34+
LOCAL_ROUTER_LOG(DEBUG) << LOG_DESC("registerNodeInfo") << printNodeInfo(nodeInfo)
35+
<< LOG_KV("updated", updated);
3536
if (ret)
3637
{
3738
// only create the frontClient when update

cpp/wedpr-transport/ppc-gateway/test/unittests/GatewayNodeInfoImplTest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ void registerNode(GatewayNodeInfoImpl::Ptr gatewayNodeInfo, int nodeSize)
7777
auto populatedNodeID = nodeID + std::to_string(i);
7878
auto nodeInfo = fakeNodeInfo(nodeInfoFactory, populatedNodeID, endPoint, components);
7979
testNodeInfoEncodeDecode(nodeInfoFactory, nodeInfo);
80-
gatewayNodeInfo->tryAddNodeInfo(nodeInfo);
80+
bool updated = false;
81+
gatewayNodeInfo->tryAddNodeInfo(nodeInfo, updated);
8182
}
8283
}
8384

docker-files/cpp/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ CMD ["--version"]
6767
FROM fiscoorg/wedpr-mpc-base-ubuntu:v3.0.0 as wedpr-mpc-service
6868
6969

70-
RUN apt-get -q update && apt-get install -qy --no-install-recommends vim libkrb5-dev python3.11 python3-pip python3-dev telnet tcpdump \
70+
RUN apt-get -q update && apt-get install -qy --no-install-recommends vim libkrb5-dev python3.11 python3-pip python3-dev telnet tcpdump net-tools\
7171
&& rm -f /usr/bin/python && ln -s /usr/bin/python3.11 /usr/bin/python \
7272
&& rm -f /usr/bin/python3 && ln -s /usr/bin/python3.11 /usr/bin/python3 \
7373
&& ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \

0 commit comments

Comments
 (0)