diff --git a/libp2p/stream/bufferstream.nim b/libp2p/stream/bufferstream.nim index 5e6577bf4..4c7e86570 100644 --- a/libp2p/stream/bufferstream.nim +++ b/libp2p/stream/bufferstream.nim @@ -35,14 +35,14 @@ import chronos import ../stream/lpstream type - WriteHandler* = proc (data: seq[byte]) {.gcsafe.} # TODO: figure out how to make this generic to avoid casts + WriteHandler* = proc (data: seq[byte]): Future[void] {.gcsafe.} # TODO: figure out how to make this generic to avoid casts BufferStream* = ref object of LPStream maxSize*: int readBuf: Deque[byte] # a deque is based on a ring buffer readReqs: Deque[Future[int]] # use dequeue to fire reads in order dataReadEvent: AsyncEvent - writeHandler: WriteHandler + writeHandler*: WriteHandler proc requestReadBytes(s: BufferStream): Future[int] = ## create a future that will complete when more @@ -236,7 +236,7 @@ method write*(s: BufferStream, ## Return number of bytes actually consumed (discarded). var buf: seq[byte] = newSeq[byte](nbytes) copyMem(addr buf[0], pbytes, nbytes) - s.writeHandler(buf) + result = s.writeHandler(buf) method write*(s: BufferStream, msg: string, @@ -251,7 +251,7 @@ method write*(s: BufferStream, ## stream. var buf = "" shallowCopy(buf, if msglen > 0: msg[0.. 0: msg[0..