non-hardcoded nodes can be called bootstrap nodes

pull/274/head
larteyoh 3 weeks ago
parent 3c3eb39376
commit 655a041b48

@ -12,6 +12,7 @@
#include "../../tools/string.hpp"
#include "../../tools/timestamp.hpp"
#include "../../database/database.hpp"
//#include "../../network/i2p.hpp"
#include <nlohmann/json.hpp>
@ -484,7 +485,7 @@ void neroshop::Node::rebuild_routing_table() {
if(port == 0) continue;
if(!ping((ip_address == this->public_ip_address) ? "127.0.0.1" : ip_address, port)) {
std::cerr << "ping: failed to ping bootstrap node\n";
std::cerr << "ping: failed to ping node\n";
// Remove unresponsive nodes from database
database->execute_params("DELETE FROM routing_table WHERE ip_address = ?1 AND port = ?2", { ip_address, std::to_string(port) });
continue;
@ -1220,7 +1221,7 @@ void neroshop::Node::on_ping(const std::vector<uint8_t>& buffer, const struct so
bool node_exists = routing_table->has_node((sender_ip == "127.0.0.1") ? this->public_ip_address : sender_ip, sender_port);
if (!node_exists) {
auto node_that_pinged = std::make_unique<Node>((sender_ip == "127.0.0.1") ? this->public_ip_address : sender_ip, sender_port, false);
if(!node_that_pinged->is_hardcoded()) { // To prevent the bootstrap node from being stored in the routing table
if(!node_that_pinged->is_hardcoded()) { // To prevent the seed node from being stored in the routing table
routing_table->add_node(std::move(node_that_pinged)); // Already has internal write_lock
persist_routing_table((sender_ip == "127.0.0.1") ? this->public_ip_address : sender_ip, sender_port);
routing_table->print_table();
@ -1600,7 +1601,7 @@ bool neroshop::Node::is_hardcoded() const {
}
bool neroshop::Node::is_bootstrap_node() const {
return (bootstrap == true) || is_hardcoded();
return (bootstrap == true);// || is_hardcoded();
}
bool neroshop::Node::is_dead() const {

@ -108,10 +108,10 @@ void rpc_server(const std::string& address) {
//-----------------------------------------------------------------------------
void ipc_server(Node& node) {
// Prevent bootstrap node from being accepted by IPC server
// Prevent seed node from being accepted by IPC server
// since its only meant to act as an initial contact point for new nodes joining the network
if (node.is_hardcoded()) {
std::cout << "Bootstrap node is not allowed to use the local IPC server. Please start another daemon instance to use the GUI\n";
std::cout << "Seed node is not allowed to use the local IPC server. Please start another daemon instance to use the GUI\n";
return;
}
@ -167,7 +167,7 @@ void dht_server(Node& node) {
// Join the DHT network
if (!node.is_hardcoded()) {
//std::shared_lock<std::shared_mutex> read_lock(node_mutex);
node.join(); // A bootstrap node cannot join the network
node.join(); // A seed node cannot join the network
}
if(node.is_hardcoded()) {

Loading…
Cancel
Save