summaryrefslogtreecommitdiff
path: root/node/Topology.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'node/Topology.cpp')
-rw-r--r--node/Topology.cpp33
1 files changed, 3 insertions, 30 deletions
diff --git a/node/Topology.cpp b/node/Topology.cpp
index 9b434732..725eed31 100644
--- a/node/Topology.cpp
+++ b/node/Topology.cpp
@@ -47,36 +47,7 @@ Topology::Topology(const RuntimeEnvironment *renv) :
_trustedPathCount(0),
_amRoot(false)
{
- std::string alls(RR->node->dataStoreGet("peers.save"));
- const uint8_t *all = reinterpret_cast<const uint8_t *>(alls.data());
- RR->node->dataStoreDelete("peers.save");
-
- Buffer<ZT_PEER_SUGGESTED_SERIALIZATION_BUFFER_SIZE> *deserializeBuf = new Buffer<ZT_PEER_SUGGESTED_SERIALIZATION_BUFFER_SIZE>();
- unsigned int ptr = 0;
- while ((ptr + 4) < alls.size()) {
- try {
- const unsigned int reclen = ( // each Peer serialized record is prefixed by a record length
- ((((unsigned int)all[ptr]) & 0xff) << 24) |
- ((((unsigned int)all[ptr + 1]) & 0xff) << 16) |
- ((((unsigned int)all[ptr + 2]) & 0xff) << 8) |
- (((unsigned int)all[ptr + 3]) & 0xff)
- );
- unsigned int pos = 0;
- deserializeBuf->copyFrom(all + ptr,reclen + 4);
- SharedPtr<Peer> p(Peer::deserializeNew(RR,RR->identity,*deserializeBuf,pos));
- ptr += pos;
- if (!p)
- break; // stop if invalid records
- if (p->address() != RR->identity.address())
- _peers.set(p->address(),p);
- } catch ( ... ) {
- break; // stop if invalid records
- }
- }
- delete deserializeBuf;
-
- clean(RR->node->now());
-
+ // Get cached world if present
std::string dsWorld(RR->node->dataStoreGet("world"));
World cachedWorld;
if (dsWorld.length() > 0) {
@@ -87,6 +58,8 @@ Topology::Topology(const RuntimeEnvironment *renv) :
cachedWorld = World(); // clear if cached world is invalid
}
}
+
+ // Use default or cached world depending on which is shinier
World defaultWorld;
{
Buffer<ZT_DEFAULT_WORLD_LENGTH> wtmp(ZT_DEFAULT_WORLD,ZT_DEFAULT_WORLD_LENGTH);