Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 6 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,50 +184,25 @@ int main()
#include <vix/console.hpp>
#include <vix/p2p/Node.hpp>
#include <vix/p2p/P2P.hpp>
#include <vix/p2p_http/P2PHttp.hpp>

using namespace vix;

int main()
{
App app;

vix::p2p::NodeConfig cfg;
cfg.node_id = "A";
cfg.node_id = "node-A";
cfg.listen_port = 9001;

auto node = vix::p2p::make_tcp_node(cfg);
vix::p2p::P2PRuntime runtime(node);
runtime.start();

vix::p2p_http::P2PHttpOptions opt;
opt.prefix = "/api/p2p";
opt.enable_ping = true;
opt.enable_status = true;
opt.enable_peers = true;
opt.enable_logs = true;
opt.enable_live_logs = true;
opt.stats_every_ms = 250;

vix::p2p_http::registerRoutes(app, runtime, opt);

app.static_dir("./public");
app.get("/", [](Request &, Response &res){
res.file("./public/index.html");
});

app.get("/connect", [](Request &, Response &res){
res.file("./public/connect.html");
});
runtime.start();

app.listen(5178, [](const vix::utils::ServerReadyInfo &info){
console.info("UI API listening on", info.port);
});
console.info("Node A running on port 9001");
runtime.wait(); // blocks

app.wait();
runtime.stop();
return 0;
}


```

---
Expand Down
2 changes: 1 addition & 1 deletion modules/p2p
Loading