1#ifndef _PAINLESS_MESH_LAYOUT_HPP_
2#define _PAINLESS_MESH_LAYOUT_HPP_
17 if (nodeTree.
nodeId == nodeId) {
20 for (
auto&& s : nodeTree.
subs) {
21 if (
contains(s, nodeId))
return true;
38 for (
auto it = tree.
subs.begin(); it != tree.
subs.end(); ++it) {
39 if (it->nodeId == nodeId) {
43 if (
forget(*it, nodeId))
return true;
61 for (
auto&& s : elsewhere.
subs) removed +=
forgetAll(tree, s);
73 uint32_t hash = 2166136261u) {
74 auto mix = [&hash](uint32_t v) {
75 for (
int i = 0; i < 4; ++i) {
76 hash ^= (v >> (8 * i)) & 0xff;
84 return hash == 0 ? 1 : hash;
101 std::list<std::shared_ptr<T> >
subs;
117 for (
auto&& s :
subs) {
118 if (s->nodeId == 0)
continue;
141 for (
auto&& sub : layout.
subs)
142 if (sub->connected()) ++live;
150 for (
auto&& sub : layout.
subs) {
151 if (sub->connected() && !sub->newConnection && sub->nodeId != 0 &&
152 sub->nodeId != changedId) {
153 sub->nodeSyncTask.forceNextIteration();
181 for (
auto&& s : tree.
subs) {
198 if (
nodeId == 0 || tree != (*
this)) {
215 req.hasTimeAuthority = subTree.hasTimeAuthority;
234 for (
auto&& s : nodeTree.
subs) {
244 if (nodeTree.
root)
return true;
252 if (
isRoot(nodeTree))
return true;
253 for (
auto&& s : nodeTree.
subs) {
263 bool includeSelf =
true) {
264 std::list<uint32_t> lst;
265 if (includeSelf) lst.push_back(nodeTree.
nodeId);
266 for (
auto&& s : nodeTree.
subs) {
267 lst.splice(lst.end(),
asList(s));
bool hasTimeAuthority
Definition layout.hpp:127
uint32_t getNodeId() const
Definition layout.hpp:108
bool isRoot() const
Definition layout.hpp:113
uint32_t nodeId
Definition layout.hpp:125
bool root
Definition layout.hpp:126
protocol::NodeTree asNodeTree()
Definition layout.hpp:115
size_t stability
Definition layout.hpp:100
std::list< std::shared_ptr< T > > subs
Definition layout.hpp:101
Definition layout.hpp:159
bool validSubs(protocol::NodeTree tree)
Definition layout.hpp:177
bool updateSubs(protocol::NodeTree tree)
Definition layout.hpp:197
protocol::NodeSyncReply reply(NodeTree &&layout)
Definition layout.hpp:222
uint32_t presented
Definition layout.hpp:169
protocol::NodeSyncRequest request(NodeTree &&layout)
Definition layout.hpp:211
Definition protocol.hpp:332
Definition protocol.hpp:277
Definition protocol.hpp:167
std::list< NodeTree > subs
Definition protocol.hpp:172
NodeTree()
Definition protocol.hpp:174
bool hasTimeAuthority
Definition protocol.hpp:171
uint32_t nodeId
Definition protocol.hpp:169
bool root
Definition protocol.hpp:170
protocol::NodeTree excludeRoute(protocol::NodeTree &&tree, uint32_t exclude)
Definition layout.hpp:87
bool isRoot(protocol::NodeTree nodeTree)
Definition layout.hpp:243
bool isRooted(protocol::NodeTree nodeTree)
Definition layout.hpp:251
bool forget(protocol::NodeTree &tree, uint32_t nodeId)
Definition layout.hpp:37
size_t liveSubs(const Layout< T > &layout)
Definition layout.hpp:139
uint32_t fingerprint(const protocol::NodeTree &tree, uint32_t hash=2166136261u)
Definition layout.hpp:72
bool contains(protocol::NodeTree nodeTree, uint32_t nodeId)
Definition layout.hpp:16
std::list< uint32_t > asList(protocol::NodeTree nodeTree, bool includeSelf=true)
Definition layout.hpp:262
size_t forgetAll(protocol::NodeTree &tree, const protocol::NodeTree &elsewhere)
Definition layout.hpp:58
void syncLayout(Layout< T > &layout, uint32_t changedId)
Definition layout.hpp:147
uint32_t size(protocol::NodeTree nodeTree)
Definition layout.hpp:232