Limiting NPL message broadcasting and forwarding to trusted nodes. (#173)

* Limiting NPL message broadcasting and forwarding to trusted nodes.
* Error fix in read_iosocket.
This commit is contained in:
Savinda Senevirathne
2020-11-30 11:11:40 +05:30
committed by GitHub
parent efbd775fa1
commit e90e9bb5dd
6 changed files with 46 additions and 14 deletions

View File

@@ -79,15 +79,17 @@ namespace p2p
// Check whether the message is qualified for message forwarding.
if (p2p::validate_for_peer_msg_forwarding(session, container, content_message_type))
{
// Npl messages are forwarded only to trusted peers.
const bool only_to_trusted_peers = content_message_type == p2pmsg::Message_Npl_Message;
if (session.need_consensus_msg_forwarding)
{
// Forward messages received by weakly connected nodes to other peers.
p2p::broadcast_message(message, false, false, &session);
p2p::broadcast_message(message, false, false, only_to_trusted_peers, &session);
}
else
{
// Forward message received from other nodes to weakly connected peers.
p2p::broadcast_message(message, false, true, &session);
p2p::broadcast_message(message, false, true, only_to_trusted_peers, &session);
}
}