NPL message refactor. (#132)

* Implemented feeding and broadcasting npl messages from the contract execution in real-time.
* Replaced npl pipe with domain sockets.
* Refactored npl read and write in nodejs echo contract
This commit is contained in:
Chalith Desaman
2020-10-14 15:18:00 +05:30
committed by GitHub
parent cb4d0c4f59
commit 5f40aebf08
9 changed files with 298 additions and 187 deletions

View File

@@ -1,5 +1,6 @@
#include "../pchheader.hpp"
#include "../conf.hpp"
#include "../consensus.hpp"
#include "../crypto.hpp"
#include "../util.hpp"
#include "../hplog.hpp"
@@ -133,14 +134,16 @@ namespace p2p
return 0;
}
std::scoped_lock<std::mutex> lock(ctx.collected_msgs.npl_messages_mutex); // Insert npl message with lock.
const p2pmsg::Npl_Message *npl_p2p_msg = content->message_as_Npl_Message();
npl_message msg;
msg.data = msg::fbuf::flatbuff_bytes_to_sv(npl_p2p_msg->data());
msg.pubkey = msg::fbuf::flatbuff_bytes_to_sv(container->pubkey());
msg.lcl = msg::fbuf::flatbuff_bytes_to_sv(container->lcl());
ctx.collected_msgs.npl_messages.push_back(std::move(msg));
if (!consensus::push_npl_message(msg))
{
LOG_DEBUG << "NPL message enqueue failure. " << session.uniqueid.substr(0, 10);
}
}
else if (content_message_type == p2pmsg::Message_State_Request_Message)
{