Added asserts.
This commit is contained in:
parent
97422a068d
commit
12abd12936
@ -6,7 +6,7 @@ This repository provides a library with interfaces by which you can access the n
|
|||||||
|
|
||||||
Network Model
|
Network Model
|
||||||
-------------
|
-------------
|
||||||
This model moves further from the federated decentralization model, taking one closer to that of torrents with their peer discovery. There are three components to the network: nodes and directory nodes. All connected machines work as nodes, but only those that are not firewalled can function as directory nodes (nodes that other nodes can connect to). With this model the directory nodes would serve the functionality of trackers in a torrent system (those nodes that have enough uptime to be considered _directory servers_). At first the network will be very much centralized around a single _directory server_, however when new _directory servers_ start popping up (any directory node with long uptimes) it will help to further remove dependence on a single point of vulnerability and help towards the decentralization of the network. Clients will remember what nodes they connected to so that upon startup they can try other directory nodes and not simply the same one, allowing for the network to quickly move forward from the original _directory server_.
|
This model moves further from the federated decentralization model, taking one closer to that of torrents with their peer discovery. There are three components to the network: nodes and directory nodes. All connected machines work as nodes, but only those that are not firewalled can function as directory nodes (nodes that other nodes can connect to). With this model the directory nodes would serve the functionality of trackers in a torrent system (those nodes that have enough uptime to be considered _directory servers_). At first the network will be very much centralized around a single directory server, however when new directory servers start popping up (any directory node with long uptimes) it will help to further remove dependence on a single point of vulnerability and help towards the decentralization of the network. Clients will remember what nodes they connected to so that upon startup they can try other directory nodes and not simply the same one, allowing for the network to quickly move forward from the original directory server.
|
||||||
|
|
||||||
For more information on the network model, please refer to the wiki.
|
For more information on the network model, please refer to the wiki.
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
int NeoComm_init_nodes(unsigned int max_nodes) {
|
int NeoComm_init_nodes(unsigned int max_nodes) {
|
||||||
if(max_nodes == 0)
|
if(max_nodes == 0)
|
||||||
@ -70,6 +71,7 @@ unsigned int NeoComm_get_node_count() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct node *NeoComm_add_node(struct address addr) {
|
struct node *NeoComm_add_node(struct address addr) {
|
||||||
|
assert(node_list);
|
||||||
if(node_count >= node_max)
|
if(node_count >= node_max)
|
||||||
return NULL;
|
return NULL;
|
||||||
for(unsigned int i = 0; i < node_max; ++i)
|
for(unsigned int i = 0; i < node_max; ++i)
|
||||||
@ -96,6 +98,7 @@ struct node *NeoComm_add_node(struct address addr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int NeoComm_remove_node(struct address addr) {
|
int NeoComm_remove_node(struct address addr) {
|
||||||
|
assert(node_list);
|
||||||
int removed = 0;
|
int removed = 0;
|
||||||
for(unsigned int i = 0; i < node_max; ++i)
|
for(unsigned int i = 0; i < node_max; ++i)
|
||||||
{
|
{
|
||||||
@ -115,6 +118,7 @@ int NeoComm_remove_node(struct address addr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct node *NeoComm_get_node(struct address addr) {
|
struct node *NeoComm_get_node(struct address addr) {
|
||||||
|
assert(node_list);
|
||||||
for(unsigned int i = 0; i < node_max; ++i)
|
for(unsigned int i = 0; i < node_max; ++i)
|
||||||
{
|
{
|
||||||
if(strcmp(node_list[i].address.address, addr.address) == 0 &&
|
if(strcmp(node_list[i].address.address, addr.address) == 0 &&
|
||||||
|
Loading…
Reference in New Issue
Block a user