rename readerwriter to stream
This commit is contained in:
parent
d23398f498
commit
3d7f657ce8
|
@ -8,9 +8,9 @@
|
|||
## those terms.
|
||||
|
||||
import chronos
|
||||
import readerwriter
|
||||
import stream
|
||||
|
||||
type ChronosStream* = ref object of ReadWrite
|
||||
type ChronosStream* = ref object of LPStream
|
||||
reader: AsyncStreamReader
|
||||
writer: AsyncStreamWriter
|
||||
server: StreamServer
|
||||
|
|
|
@ -8,16 +8,16 @@
|
|||
## those terms.
|
||||
|
||||
import chronos
|
||||
import peerinfo, multiaddress, readerwriter, peerinfo, varint, vbuffer
|
||||
import peerinfo, multiaddress, stream, peerinfo, varint, vbuffer
|
||||
|
||||
const DefaultReadSize: uint = 64*1024
|
||||
|
||||
type
|
||||
Connection* = ref object of ReadWrite
|
||||
Connection* = ref object of LPStream
|
||||
peerInfo*: PeerInfo
|
||||
stream: ReadWrite
|
||||
stream: LPStream
|
||||
|
||||
proc newConnection*(stream: ReadWrite): Connection =
|
||||
proc newConnection*(stream: LPStream): Connection =
|
||||
## create a new Connection for the specified async reader/writer
|
||||
new result
|
||||
result.stream = stream
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
## Nim-LibP2P
|
||||
## Copyright (c) 2018 Status Research & Development GmbH
|
||||
## Licensed under either of
|
||||
## * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
|
||||
## * MIT license ([LICENSE-MIT](LICENSE-MIT))
|
||||
## at your option.
|
||||
## This file may not be copied, modified, or distributed except according to
|
||||
## those terms.
|
||||
|
||||
import chronos
|
||||
|
||||
type LPStream* = ref object of RootObj
|
||||
closed*: bool
|
||||
|
||||
method read*(s: LPStream, n = -1): Future[seq[byte]]
|
||||
{.base, async.} =
|
||||
discard
|
||||
|
||||
method readExactly*(s: LPStream, pbytes: pointer, nbytes: int): Future[void]
|
||||
{.base, async.} =
|
||||
discard
|
||||
|
||||
method readLine*(s: LPStream, limit = 0, sep = "\r\n"): Future[string]
|
||||
{.base, async.} =
|
||||
discard
|
||||
|
||||
method readOnce*(s: LPStream, pbytes: pointer, nbytes: int): Future[int]
|
||||
{.base, async.} =
|
||||
discard
|
||||
|
||||
method readUntil*(s: LPStream,
|
||||
pbytes: pointer, nbytes: int,
|
||||
sep: seq[byte]): Future[int]
|
||||
{.base, async.} =
|
||||
discard
|
||||
|
||||
method write*(s: LPStream, pbytes: pointer, nbytes: int)
|
||||
{.base, async.} =
|
||||
discard
|
||||
|
||||
method write*(s: LPStream, msg: string, msglen = -1)
|
||||
{.base, async.} =
|
||||
discard
|
||||
|
||||
method write*(s: LPStream, msg: seq[byte], msglen = -1)
|
||||
{.base, async.} =
|
||||
discard
|
||||
|
||||
method close*(s: LPStream)
|
||||
{.base, async.} =
|
||||
discard
|
|
@ -8,7 +8,7 @@
|
|||
## those terms.
|
||||
|
||||
import chronos
|
||||
import peerinfo, connection, multiaddress, multicodec, readerwriter
|
||||
import peerinfo, connection, multiaddress, multicodec
|
||||
|
||||
type
|
||||
ConnHandler* = proc (conn: Connection): Future[void] {.gcsafe.}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import unittest, strutils, sequtils, sugar
|
||||
import chronos
|
||||
import ../libp2p/connection, ../libp2p/multistreamselect,
|
||||
../libp2p/readerwriter, ../libp2p/connection, ../libp2p/multiaddress,
|
||||
../libp2p/stream, ../libp2p/connection, ../libp2p/multiaddress,
|
||||
../libp2p/transport, ../libp2p/tcptransport
|
||||
|
||||
## Mock stream for select test
|
||||
type
|
||||
TestSelectStream = ref object of ReadWrite
|
||||
TestSelectStream = ref object of LPStream
|
||||
step*: int
|
||||
|
||||
method readExactly*(s: TestSelectStream,
|
||||
|
@ -41,7 +41,7 @@ proc newTestSelectStream(): TestSelectStream =
|
|||
|
||||
## Mock stream for handles test
|
||||
type
|
||||
TestHandlesStream = ref object of ReadWrite
|
||||
TestHandlesStream = ref object of LPStream
|
||||
step*: int
|
||||
|
||||
method readExactly*(s: TestHandlesStream,
|
||||
|
@ -78,7 +78,7 @@ proc newTestHandlesStream(): TestHandlesStream =
|
|||
type
|
||||
LsHandler = proc(procs: seq[byte]): Future[void]
|
||||
|
||||
TestLsStream = ref object of ReadWrite
|
||||
TestLsStream = ref object of LPStream
|
||||
step*: int
|
||||
ls*: LsHandler
|
||||
|
||||
|
@ -121,7 +121,7 @@ proc newTestLsStream(ls: LsHandler): TestLsStream =
|
|||
type
|
||||
NaHandler = proc(procs: string): Future[void]
|
||||
|
||||
TestNaStream = ref object of ReadWrite
|
||||
TestNaStream = ref object of LPStream
|
||||
step*: int
|
||||
na*: NaHandler
|
||||
|
||||
|
|
Loading…
Reference in New Issue