fix: use exact types for mplex id

This commit is contained in:
Dmitriy Ryajov 2020-03-23 11:14:06 -06:00
parent a2acdd7933
commit 2de98751ae
3 changed files with 14 additions and 14 deletions

View File

@ -22,7 +22,7 @@ const DefaultChannelSize* = 1 shl 20
type
Msg* = tuple
id: uint
id: uint64
msgType: MessageType
data: seq[byte]
@ -61,10 +61,10 @@ proc readMsg*(conn: Connection): Future[Msg] {.async, gcsafe.} =
trace "read data", data = data.len
let header = headerVarint
result = (header shr 3, MessageType(header and 0x7), data)
result = (uint64(header shr 3), MessageType(header and 0x7), data)
proc writeMsg*(conn: Connection,
id: uint,
id: uint64,
msgType: MessageType,
data: seq[byte] = @[]) {.async, gcsafe.} =
trace "seding data over mplex", id,
@ -81,7 +81,7 @@ proc writeMsg*(conn: Connection,
trace "unable to send message", exc = exc.msg
proc writeMsg*(conn: Connection,
id: uint,
id: uint64,
msgType: MessageType,
data: string) {.async, gcsafe.} =
result = conn.writeMsg(id, msgType, cast[seq[byte]](data))

View File

@ -21,7 +21,7 @@ logScope:
type
LPChannel* = ref object of BufferStream
id*: uint
id*: uint64
name*: string
conn*: Connection
initiator*: bool
@ -35,7 +35,7 @@ type
closeCode*: MessageType
resetCode*: MessageType
proc newChannel*(id: uint,
proc newChannel*(id: uint64,
conn: Connection,
initiator: bool,
name: string = "",

View File

@ -28,12 +28,12 @@ const DefaultRWTimeout = InfiniteDuration
type
Mplex* = ref object of Muxer
remote*: Table[uint, LPChannel]
local*: Table[uint, LPChannel]
currentId*: uint
maxChannels*: uint
remote*: Table[uint64, LPChannel]
local*: Table[uint64, LPChannel]
currentId*: uint64
maxChannels*: uint64
proc getChannelList(m: Mplex, initiator: bool): var Table[uint, LPChannel] =
proc getChannelList(m: Mplex, initiator: bool): var Table[uint64, LPChannel] =
if initiator:
trace "picking local channels", initiator = initiator
result = m.local
@ -43,7 +43,7 @@ proc getChannelList(m: Mplex, initiator: bool): var Table[uint, LPChannel] =
proc newStreamInternal*(m: Mplex,
initiator: bool = true,
chanId: uint = 0,
chanId: uint64 = 0,
name: string = "",
lazy: bool = false):
Future[LPChannel] {.async, gcsafe.} =
@ -134,8 +134,8 @@ proc newMplex*(conn: Connection,
new result
result.connection = conn
result.maxChannels = maxChanns
result.remote = initTable[uint, LPChannel]()
result.local = initTable[uint, LPChannel]()
result.remote = initTable[uint64, LPChannel]()
result.local = initTable[uint64, LPChannel]()
let m = result
conn.closeEvent.wait()