Regularly store nodes.
This commit is contained in:
parent
374bef35dc
commit
4a5743c67b
@ -21,8 +21,14 @@ namespace Components
|
||||
}
|
||||
}
|
||||
|
||||
void Node::StoreNodes()
|
||||
void Node::StoreNodes(bool force)
|
||||
{
|
||||
static int lastStorage = 0;
|
||||
|
||||
// Don't store nodes if the delta is too small and were not forcing it
|
||||
if ((Game::Com_Milliseconds() - lastStorage) < NODE_STORE_INTERVAL && !force) return;
|
||||
lastStorage = Game::Com_Milliseconds();
|
||||
|
||||
std::vector<Node::AddressEntry> entries;
|
||||
|
||||
for (auto entry : Node::Nodes)
|
||||
@ -291,7 +297,7 @@ namespace Components
|
||||
|
||||
if (Dedicated::IsDedicated() && node.state == Node::STATE_VALID)
|
||||
{
|
||||
if (heartbeatCount < HEARTBEATS_FRAME_LIMIT && (!node.lastHeartbeat || (Game::Com_Milliseconds() - node.lastHeartbeat) >(HEARTBEAT_INTERVAL)))
|
||||
if (heartbeatCount < HEARTBEATS_FRAME_LIMIT && (!node.lastHeartbeat || (Game::Com_Milliseconds() - node.lastHeartbeat) > (HEARTBEAT_INTERVAL)))
|
||||
{
|
||||
heartbeatCount++;
|
||||
|
||||
@ -337,8 +343,7 @@ namespace Components
|
||||
|
||||
Node::DeleteInvalidNodes();
|
||||
Node::DeleteInvalidDedis();
|
||||
|
||||
count = 0;
|
||||
Node::StoreNodes(false);
|
||||
}
|
||||
|
||||
void Node::DeleteInvalidDedis()
|
||||
@ -565,7 +570,8 @@ namespace Components
|
||||
|
||||
Node::~Node()
|
||||
{
|
||||
Node::StoreNodes();
|
||||
Node::StoreNodes(true);
|
||||
Node::Nodes.clear();
|
||||
Node::Dedis.clear();
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,8 @@
|
||||
#define NODE_PACKET_LIMIT 111 // Send 111 nodes per synchronization packet
|
||||
#define DEDI_PACKET_LIMIT 111 // Send 111 dedis per synchronization packet
|
||||
|
||||
#define NODE_STORE_INTERVAL 1000 * 60* 1 // Store nodes every minute
|
||||
|
||||
namespace Components
|
||||
{
|
||||
class Node : public Component
|
||||
@ -86,7 +88,7 @@ namespace Components
|
||||
static std::vector<DediEntry> Dedis;
|
||||
|
||||
static void LoadNodes();
|
||||
static void StoreNodes();
|
||||
static void StoreNodes(bool force);
|
||||
|
||||
static void AddNode(Network::Address address, bool valid = false);
|
||||
static void AddDedi(Network::Address address, bool dirty = false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user