Skip to content

Commit

Permalink
update #2, sending part, relaxed blacklisting policy
Browse files Browse the repository at this point in the history
  • Loading branch information
art-gor committed Mar 17, 2023
1 parent 48e6bf0 commit e9462f7
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 130 deletions.
22 changes: 11 additions & 11 deletions src/libNetwork/P2P.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void SendMessageImpl(const std::shared_ptr<SendJobs>& sendJobs,
}

static const zbytes no_hash;
auto raw_msg = zil::p2p::CreateMessage(message, no_hash, startByteType,
auto raw_msg = CreateMessage(message, no_hash, startByteType,
inject_trace_context);

for (const auto& peer : peers) {
Expand Down Expand Up @@ -176,7 +176,7 @@ namespace {

template <typename PeerList>
void SendBroadcastMessageImpl(
const std::shared_ptr<zil::p2p::SendJobs>& sendJobs, const PeerList& peers,
const std::shared_ptr<SendJobs>& sendJobs, const PeerList& peers,
const std::optional<Peer>& selfPeer, const zbytes& message, zbytes& hash,
bool inject_trace_context) {
if (message.size() <= MessageOffset::BODY) {
Expand All @@ -196,8 +196,8 @@ void SendBroadcastMessageImpl(
sha256.Update(message);
hash = sha256.Finalize();

auto raw_msg = zil::p2p::CreateMessage(
message, hash, zil::p2p::START_BYTE_BROADCAST, inject_trace_context);
auto raw_msg = CreateMessage(
message, hash, START_BYTE_BROADCAST, inject_trace_context);

std::string hashStr;
if (selfPeer) {
Expand Down Expand Up @@ -258,7 +258,7 @@ void P2P::SendMessageNoQueue(const Peer& peer, const zbytes& message,
}

if (!m_sendJobs) {
m_sendJobs = zil::p2p::SendJobs::Create();
m_sendJobs = SendJobs::Create();
}
m_sendJobs->SendMessageToPeerSynchronous(peer, message, startByteType);
}
Expand Down Expand Up @@ -355,14 +355,14 @@ bool P2P::DispatchMessage(const Peer& from, ReadMessageResult& result) {
}

ProcessBroadCastMsg(result.message, result.hash, from, result.traceInfo);
} else if (result.startByte == zil::p2p::START_BYTE_NORMAL) {
} else if (result.startByte == START_BYTE_NORMAL) {
LOG_PAYLOAD(INFO, "Incoming normal " << from, result.message,
Logger::MAX_BYTES_TO_DISPLAY);

// Queue the message
m_dispatcher(MakeMsg(std::move(result.message), from,
zil::p2p::START_BYTE_NORMAL, result.traceInfo));
} else if (result.startByte == zil::p2p::START_BYTE_GOSSIP) {
START_BYTE_NORMAL, result.traceInfo));
} else if (result.startByte == START_BYTE_GOSSIP) {
// Check for the maximum gossiped-message size
if (result.message.size() >= MAX_GOSSIP_MSG_SIZE_IN_BYTES) {
LOG_GENERAL(WARNING,
Expand Down Expand Up @@ -444,7 +444,7 @@ void P2P::ProcessBroadCastMsg(zbytes& message, zbytes& hash, const Peer& from,
<< msgHashStr.substr(0, 6) << "] RECV");

// Queue the message
m_dispatcher(MakeMsg(std::move(message), from, zil::p2p::START_BYTE_BROADCAST,
m_dispatcher(MakeMsg(std::move(message), from, START_BYTE_BROADCAST,
traceInfo));
}

Expand Down Expand Up @@ -479,7 +479,7 @@ void P2P::ProcessGossipMsg(zbytes& message, const Peer& from,

// Queue the message
m_dispatcher(MakeMsg(std::move(tmp), remoteListener,
zil::p2p::START_BYTE_GOSSIP, traceInfo));
START_BYTE_GOSSIP, traceInfo));
}
} else {
auto resp = m_rumorManager->RumorReceived((unsigned int)gossipMsgTyp,
Expand All @@ -490,7 +490,7 @@ void P2P::ProcessGossipMsg(zbytes& message, const Peer& from,

// Queue the message
m_dispatcher(MakeMsg(std::move(resp.second), remoteListener,
zil::p2p::START_BYTE_GOSSIP, traceInfo));
START_BYTE_GOSSIP, traceInfo));
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/libNetwork/P2P.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,18 @@ class P2P {

/// Multicasts message to specified list of peers.
void SendMessage(const VectorOfPeer& peers, const zbytes& message,
unsigned char startByteType = zil::p2p::START_BYTE_NORMAL,
unsigned char startByteType = START_BYTE_NORMAL,
bool inject_trace_context = false);

/// Multicasts message to specified list of peers.
void SendMessage(const std::deque<Peer>& peers, const zbytes& message,
unsigned char startByteType = zil::p2p::START_BYTE_NORMAL,
unsigned char startByteType = START_BYTE_NORMAL,
bool inject_trace_context = false,
bool bAllowSendToRelaxedBlacklist = false);

/// Sends normal message to specified peer.
void SendMessage(const Peer& peer, const zbytes& message,
unsigned char startByteType = zil::p2p::START_BYTE_NORMAL,
unsigned char startByteType = START_BYTE_NORMAL,
bool inject_trace_context = false);

/// Multicasts message of type=broadcast to specified list of peers.
Expand All @@ -91,7 +91,7 @@ class P2P {
/// Special case for cmd line utilities only - blocking
void SendMessageNoQueue(
const Peer& peer, const zbytes& message,
unsigned char startByteType = zil::p2p::START_BYTE_NORMAL);
unsigned char startByteType = START_BYTE_NORMAL);

bool SpreadRumor(const zbytes& message);

Expand Down
Loading

0 comments on commit e9462f7

Please sign in to comment.