Some commented out functions to enable later.

The next release of OpenDHT should contain the fixes for this.
This commit is contained in:
Nicolás Ortega Froysa 2017-09-20 10:54:33 +02:00
parent 5ab7a7bb5b
commit d706702a4e
No known key found for this signature in database
GPG Key ID: FEC70E3BAE2E69BF

View File

@ -18,8 +18,11 @@
#include "neocomm.h"
#include "error.hpp"
#include <opendht.h>
#include <string>
#include <fstream>
static dht::DhtRunner node;
@ -34,3 +37,42 @@ void NeoComm_deinit() {
void NeoComm_connect(const char *address, const unsigned short port) {
node.bootstrap(address, std::to_string(port));
}
// NOTICE: When the new OpenDHT release comes out this code should work.
// Meanwhile just keep it commented out.
/*int NeoComm_import_nodes(const char *node_file) {
msgpack::unpacker upak;
{
std::ifstream import_file(node_file, std::ios::binary bitor
std::ios::ate);
if(not import_file.is_open())
{
add_error(std::string("Failed to open file ") + node_file);
return 0;
}
auto file_size = import_file.tellg();
import_file.seekg(0, std::ios::beg);
upak.reserve_buffer(file_size);
import_file.read(upak.buffer(), file_size);
upak.buffer_consumed(file_size);
}
msgpack::object_handle obj_handler;
while(upak.next(obj_handler))
{
auto imported_nodes =
obj_handler.get().as<std::vector<dht::NodeExport>>();
node.bootstrap(imported_nodes);
}
return 1;
}*/
/*int NeoComm_export_nodes(const char *node_file) {
std::ofstream export_file(node_file, std::ios::binary);
if(not export_file.is_open())
{
add_error(std::string("Failed to open file ") + node_file);
return 0;
}
msgpack::pack(export_file, node.exportNodes());
}*/