diff --git a/libp2p/muxers/mplex/lpchannel.nim b/libp2p/muxers/mplex/lpchannel.nim index 27cf6e237..0eb665b90 100644 --- a/libp2p/muxers/mplex/lpchannel.nim +++ b/libp2p/muxers/mplex/lpchannel.nim @@ -55,7 +55,7 @@ proc newChannel*(id: uint, proc writeHandler(data: seq[byte]): Future[void] {.async, gcsafe.} = # writes should happen in sequence await chan.asyncLock.acquire() - info "writeHandler: sending data ", data = data.toHex(), id = chan.id + trace "writeHandler: sending data ", data = data.toHex(), id = chan.id await conn.writeMsg(chan.id, chan.msgCode, data) # write header chan.asyncLock.release() diff --git a/libp2p/protocols/pubsub/floodsub.nim b/libp2p/protocols/pubsub/floodsub.nim index e0118db39..979ebb6c2 100644 --- a/libp2p/protocols/pubsub/floodsub.nim +++ b/libp2p/protocols/pubsub/floodsub.nim @@ -105,7 +105,7 @@ proc handleConn(f: FloodSub, ## if conn.peerInfo.peerId.isNone: - debug "no valid PeerId for peer" + trace "no valid PeerId for peer" return # create new pubsub peer diff --git a/libp2p/protocols/secure/secio.nim b/libp2p/protocols/secure/secio.nim index b92a3fcb6..c473ba1f0 100644 --- a/libp2p/protocols/secure/secio.nim +++ b/libp2p/protocols/secure/secio.nim @@ -188,14 +188,14 @@ proc readMessage*(sconn: SecureConnection): Future[seq[byte]] {.async.} = if sconn.macCheckAndDecode(buf): result = buf else: - debug "Message MAC verification failed", buf = toHex(buf) + trace "Message MAC verification failed", buf = toHex(buf) else: - debug "Received message header size is more then allowed", + trace "Received message header size is more then allowed", length = length, allowed_length = SecioMaxMessageSize except AsyncStreamIncompleteError: - debug "Connection dropped while reading" + trace "Connection dropped while reading" except AsyncStreamReadError: - debug "Error reading from connection" + trace "Error reading from connection" proc writeMessage*(sconn: SecureConnection, message: seq[byte]) {.async.} = ## Write message ``message`` to secure connection ``sconn``. @@ -215,7 +215,7 @@ proc writeMessage*(sconn: SecureConnection, message: seq[byte]) {.async.} = try: await sconn.conn.write(msg) except AsyncStreamWriteError: - debug "Could not write to connection" + trace "Could not write to connection" proc newSecureConnection*(conn: Connection, hash: string, cipher: string, secrets: Secret, @@ -292,7 +292,7 @@ proc handshake*(s: Secio, conn: Connection): Future[SecureConnection] {.async.} localPeerId = PeerID.init(s.localPublicKey) - debug "Local proposal", schemes = SecioExchanges, ciphers = SecioCiphers, + trace "Local proposal", schemes = SecioExchanges, ciphers = SecioCiphers, hashes = SecioHashes, pubkey = toHex(localBytesPubkey), peer = localPeerId @@ -318,7 +318,7 @@ proc handshake*(s: Secio, conn: Connection): Future[SecureConnection] {.async.} let order = getOrder(remoteBytesPubkey, localNonce, localBytesPubkey, remoteNonce) - debug "Remote proposal", schemes = remoteExchanges, ciphers = remoteCiphers, + trace "Remote proposal", schemes = remoteExchanges, ciphers = remoteCiphers, hashes = remoteHashes, pubkey = toHex(remoteBytesPubkey), order = order, peer = remotePeerId @@ -327,10 +327,10 @@ proc handshake*(s: Secio, conn: Connection): Future[SecureConnection] {.async.} let cipher = selectBest(order, SecioCiphers, remoteCiphers) let hash = selectBest(order, SecioHashes, remoteHashes) if len(scheme) == 0 or len(cipher) == 0 or len(hash) == 0: - debug "No algorithms in common", peer = remotePeerId + trace "No algorithms in common", peer = remotePeerId return - debug "Encryption scheme selected", scheme = scheme, cipher = cipher, + trace "Encryption scheme selected", scheme = scheme, cipher = cipher, hash = hash var ekeypair = ephemeral(scheme) @@ -357,15 +357,15 @@ proc handshake*(s: Secio, conn: Connection): Future[SecureConnection] {.async.} var remoteCorpus = answer & request[4..^1] & remoteEBytesPubkey if not remoteESignature.verify(remoteCorpus, remotePubkey): - debug "Signature verification failed", scheme = remotePubkey.scheme, + trace "Signature verification failed", scheme = remotePubkey.scheme, signature = remoteESignature, pubkey = remotePubkey, corpus = remoteCorpus return - debug "Signature verified", scheme = remotePubkey.scheme + trace "Signature verified", scheme = remotePubkey.scheme if not remoteEPubkey.eckey.initRaw(remoteEBytesPubkey): - debug "Remote ephemeral public key incorrect or corrupted", + trace "Remote ephemeral public key incorrect or corrupted", pubkey = toHex(remoteEBytesPubkey) return @@ -393,11 +393,11 @@ proc handshake*(s: Secio, conn: Connection): Future[SecureConnection] {.async.} var res = await result.readMessage() if res != @localNonce: - debug "Nonce verification failed", receivedNonce = toHex(res), + trace "Nonce verification failed", receivedNonce = toHex(res), localNonce = toHex(localNonce) raise newException(CatchableError, "Nonce verification failed") else: - debug "Secure handshake succeeded" + trace "Secure handshake succeeded" proc readLoop(sconn: SecureConnection, stream: BufferStream) {.async.} = while not sconn.conn.closed: @@ -413,7 +413,7 @@ proc readLoop(sconn: SecureConnection, stream: BufferStream) {.async.} = proc handleConn(s: Secio, conn: Connection): Future[Connection] {.async.} = var sconn = await s.handshake(conn) proc writeHandler(data: seq[byte]) {.async, gcsafe.} = - debug "sending encrypted bytes", bytes = data.toHex() + trace "sending encrypted bytes", bytes = data.toHex() await sconn.writeMessage(data) var stream = newBufferStream(writeHandler) diff --git a/libp2p/switch.nim b/libp2p/switch.nim index f802f69e3..baaf63d8a 100644 --- a/libp2p/switch.nim +++ b/libp2p/switch.nim @@ -288,7 +288,7 @@ proc newSwitch*(peerInfo: PeerInfo, let s = result # can't capture result result.streamHandler = proc(stream: Connection) {.async, gcsafe.} = - debug "handling connection for", peerInfo = stream.peerInfo + trace "handling connection for", peerInfo = stream.peerInfo await s.ms.handle(stream) # handle incoming connection result.mount(identity) diff --git a/libp2p/transports/tcptransport.nim b/libp2p/transports/tcptransport.nim index 095a396b8..a8bf39d2e 100644 --- a/libp2p/transports/tcptransport.nim +++ b/libp2p/transports/tcptransport.nim @@ -67,7 +67,7 @@ method listen*(t: TcpTransport, # always get the resolved address in case we're bound to 0.0.0.0:0 t.ma = MultiAddress.init(t.server.sock.getLocalAddress()) result = t.server.join() - debug "started node on", address = t.ma + trace "started node on", address = t.ma method dial*(t: TcpTransport, address: MultiAddress): diff --git a/libp2p/transports/transport.nim b/libp2p/transports/transport.nim index 1e196cd06..c10136943 100644 --- a/libp2p/transports/transport.nim +++ b/libp2p/transports/transport.nim @@ -47,7 +47,7 @@ method listen*(t: Transport, ## listen for incoming connections t.ma = ma t.handler = handler - debug "starting node", address = $ma + trace "starting node", address = $ma method dial*(t: Transport, address: MultiAddress): diff --git a/tests/test.nim b/tests/test.nim index 0e78bdb95..541ac85ee 100644 --- a/tests/test.nim +++ b/tests/test.nim @@ -76,13 +76,13 @@ proc main() {.async.} = await switch.subscribeToPeer(remotePeer) proc handler(topic: string, data: seq[byte]): Future[void] {.closure, gcsafe.} = - debug "IN HANDLER" + trace "IN HANDLER" let topic = Base58.encode(cast[seq[byte]]("chat")) await switch.subscribe(topic, handler) let msg = cast[seq[byte]]("hello from nim") await switch.publish(topic, msg) - # debug "published message from test" + # trace "published message from test" # TODO: for some reason the connection closes unless I do a forever loop await allFutures(libp2pFuts) diff --git a/tests/testmplex.nim b/tests/testmplex.nim index adb1105c5..1bd44dd2e 100644 --- a/tests/testmplex.nim +++ b/tests/testmplex.nim @@ -237,7 +237,7 @@ suite "Mplex": mplexListen.streamHandler = handleMplexListen listenFut = mplexListen.handle() listenFut.addCallback(proc(udata: pointer) {.gcsafe.} - = debug "completed listener") + = trace "completed listener") let transport1: TcpTransport = newTransport(TcpTransport) asyncCheck transport1.listen(ma, connHandler) @@ -248,7 +248,7 @@ suite "Mplex": let mplexDial = newMplex(conn) let dialFut = mplexDial.handle() dialFut.addCallback(proc(udata: pointer = nil) {.gcsafe.} - = debug "completed dialer") + = trace "completed dialer") for i in 1..10: let stream = await mplexDial.newStream("dialer stream") await stream.writeLp(&"stream {i} from dialer!")