hive.py now defaults to 1000 relays because f your box.

also check for error on uv_async_init...

may want to `ulimit -Sn $(ulimit -Hn)`...
pull/1184/head
Thomas Winget 4 years ago
parent c8c66f0a5f
commit a58a8c9a61

@ -127,6 +127,7 @@ namespace llarp
return false;
if(txid == 0) // txid == 0 on gossip
{
LogWarn("Received Gossiped RC, generating RCGossipReceivedEvent");
auto *router = dht.GetRouter();
tooling::RouterEventPtr event = std::make_unique<tooling::RCGossipReceivedEvent>(router->pubkey(), rc);
router->NotifyRouterEvent(std::move(event));

@ -782,14 +782,20 @@ namespace libuv
uv_loop_configure(&m_Impl, UV_LOOP_BLOCK_SIGNAL, SIGPIPE);
#endif
m_LogicCaller.data = this;
uv_async_init(&m_Impl, &m_LogicCaller, [](uv_async_t* h) {
int err;
if ((err = uv_async_init(&m_Impl, &m_LogicCaller, [](uv_async_t* h) {
Loop* l = static_cast< Loop* >(h->data);
while(not l->m_LogicCalls.empty())
{
auto f = l->m_LogicCalls.popFront();
f();
}
});
})) != 0)
{
llarp::LogError("Libuv uv_async_init returned error: ", uv_strerror(err));
return false;
}
m_TickTimer = new uv_timer_t;
m_TickTimer->data = this;
m_Run.store(true);

@ -30,7 +30,7 @@ namespace llarp
RCGossiper::ShouldGossipOurRC(Time_t now) const
{
bool should = now >= (m_LastGossipedOurRC + GossipOurRCInterval);
LogWarn("ShouldGossipOurRC: ", should);
LogWarn("ShouldGossipOurRC: ", should);
return should;
}
@ -74,6 +74,7 @@ namespace llarp
m_LastGossipedOurRC = now;
}
LogWarn("Creating RC Gossip Message");
// send a GRCM as gossip method
DHTImmediateMessage gossip;
gossip.msgs.emplace_back(
@ -81,13 +82,16 @@ namespace llarp
// send it to everyone
m_LinkManager->ForEachPeer([&](ILinkSession* peerSession) {
LogWarn("Considering Peer to send RC Gossip Message");
// ensure connected session
if(not(peerSession && peerSession->IsEstablished()))
return;
LogWarn("Peer has session established to send RC Gossip Message");
// check if public router
const auto other_rc = peerSession->GetRemoteRC();
if(not other_rc.IsPublicRouter())
return;
LogWarn("Peer is public router to send RC Gossip Message");
// encode message
ILinkSession::Message_t msg;
msg.resize(MAX_LINK_MSG_SIZE / 2);
@ -96,6 +100,7 @@ namespace llarp
return;
msg.resize(buf.cur - buf.base);
// send message
LogWarn("Sending RC Gossip Message to ", RouterID(other_rc.pubkey).ShortString());
peerSession->SendMessageBuffer(std::move(msg), nullptr);
});
return true;

@ -209,27 +209,29 @@ def main(n_relays=10, n_clients=10, print_each_event=True):
total_events = 0
event_counts = dict()
while running:
event = hive.PopEvent()
event_name = event.__class__.__name__
if event:
if print_each_event:
print("Event: %s -- Triggered: %s" % (event_name, event.triggered))
print(event)
hops = getattr(event, "hops", None)
if hops:
for hop in hops:
print(hop)
total_events = total_events + 1
if event_name in event_counts:
event_counts[event_name] = event_counts[event_name] + 1
else:
event_counts[event_name] = 1
if total_events % 10 == 0:
pprint(event_counts)
sleep(.01)
hive.CollectAllEvents()
for event in hive.events:
event_name = event.__class__.__name__
if event:
if print_each_event:
print("Event: %s -- Triggered: %s" % (event_name, event.triggered))
print(event)
hops = getattr(event, "hops", None)
if hops:
for hop in hops:
print(hop)
total_events = total_events + 1
if event_name in event_counts:
event_counts[event_name] = event_counts[event_name] + 1
else:
event_counts[event_name] = 1
if total_events % 10 == 0:
pprint(event_counts)
hive.events = []
sleep(.1)
print('stopping')
hive.Stop()
@ -241,4 +243,4 @@ if __name__ == '__main__':
print_events = False
parser.add_argument('--print-events', dest="print_events", action='store_true')
args = parser.parse_args()
main(n_relays=30, print_each_event = args.print_events)
main(n_relays=1000, print_each_event = args.print_events)

Loading…
Cancel
Save