gossipsub fixes

This commit is contained in:
Dmitriy Ryajov 2020-05-21 09:01:36 -06:00
parent 6112de746d
commit d4bdb42046
3 changed files with 55 additions and 74 deletions

View File

@ -135,6 +135,7 @@ method handleConn*(p: PubSub,
## that we're interested in
##
try:
if isNil(conn.peerInfo):
trace "no valid PeerId for peer"
await conn.close()
@ -152,7 +153,9 @@ method handleConn*(p: PubSub,
peer.handler = handler
await peer.handle(conn) # spawn peer read loop
trace "pubsub peer handler ended, cleaning up"
await p.internalCleanup(conn)
await p.internalClenaup(conn)
except CatchableError as exc:
trace "exception ocurred in pubsub handle", exc = exc.msg
method subscribeToPeer*(p: PubSub,
conn: Connection) {.base, async.} =

View File

@ -436,7 +436,6 @@ method write*(sconn: NoiseConnection, message: seq[byte]): Future[void] {.async.
if message.len == 0:
return
try:
var
left = message.len
offset = 0
@ -455,16 +454,6 @@ method write*(sconn: NoiseConnection, message: seq[byte]): Future[void] {.async.
outbuf &= besize
outbuf &= cipher
await sconn.stream.write(outbuf)
except LPStreamEOFError:
trace "Ignoring EOF while writing"
except CancelledError as exc:
raise exc
except CatchableError as exc:
# TODO these exceptions are ignored since it's likely that if writes are
# are failing, the underlying connection is already closed - this needs
# more cleanup though
debug "Could not write to connection", error = exc.name
trace "Could not write to connection - verbose", msg = exc.msg
method handshake*(p: Noise, conn: Connection, initiator: bool = false): Future[SecureConn] {.async.} =
trace "Starting Noise handshake", initiator

View File

@ -212,7 +212,6 @@ method write*(sconn: SecioConn, message: seq[byte]) {.async.} =
if message.len == 0:
return
try:
var
left = message.len
offset = 0
@ -236,16 +235,6 @@ method write*(sconn: SecioConn, message: seq[byte]) {.async.} =
trace "Writing message", message = msg.shortLog, left, offset
await sconn.stream.write(msg)
except LPStreamEOFError:
trace "Ignoring EOF while writing"
except CancelledError as exc:
raise exc
except CatchableError as exc:
# TODO these exceptions are ignored since it's likely that if writes are
# are failing, the underlying connection is already closed - this needs
# more cleanup though
debug "Could not write to connection", error = exc.name
trace "Could not write to connection - verbose", msg = exc.msg
proc newSecioConn(conn: Connection,
hash: string,