aboutsummaryrefslogtreecommitdiff
path: root/test/test_p2p.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_p2p.cpp')
-rw-r--r--test/test_p2p.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/test/test_p2p.cpp b/test/test_p2p.cpp
index 14304eb..7f80f85 100644
--- a/test/test_p2p.cpp
+++ b/test/test_p2p.cpp
@@ -87,8 +87,14 @@ struct Net {
this->id, fatal ? "fatal" : "recoverable", err.what());
}
});
- net->reg_unknown_peer_handler([this](const NetAddr &addr) {
- fprintf(stdout, "net %lu: unknown peer attempts to connnect %s\n", this->id, std::string(addr).c_str());
+ net->reg_peer_handler([this](const PeerNetwork::conn_t &conn, bool connected) {
+ fprintf(stdout, "net %lu: %s peer %s\n", this->id,
+ connected ? "connected to" : "disconnected from",
+ std::string(conn->get_peer_addr()).c_str());
+ });
+ net->reg_unknown_peer_handler([this](const NetAddr &claimed_addr) {
+ fprintf(stdout, "net %lu: unknown peer %s attempts to connnect\n",
+ this->id, std::string(claimed_addr).c_str());
});
th = std::thread([=](){
try {
@@ -258,8 +264,8 @@ int main(int argc, char **argv) {
fprintf(stdout,
"add <node-id> <port> -- start a node (create a PeerNetwork instance)\n"
"addpeer <node-id> <peer-id> -- add a peer to a given node\n"
- "rmpeer <node-id> <peer-id> -- add a peer to a given node\n"
- "rm <node-id> -- remove a node (destroy a PeerNetwork instance)\n"
+ "delpeer <node-id> <peer-id> -- add a peer to a given node\n"
+ "del <node-id> -- remove a node (destroy a PeerNetwork instance)\n"
"msg <node-id> <peer-id> <msg> -- send a text message to a node\n"
"ls -- list all node ids\n"
"exit -- quit the program\n"