mirror of https://github.com/vacp2p/nim-libp2p.git
fix: use exact types for mplex id
This commit is contained in:
parent
a2acdd7933
commit
2de98751ae
|
@ -22,7 +22,7 @@ const DefaultChannelSize* = 1 shl 20
|
||||||
|
|
||||||
type
|
type
|
||||||
Msg* = tuple
|
Msg* = tuple
|
||||||
id: uint
|
id: uint64
|
||||||
msgType: MessageType
|
msgType: MessageType
|
||||||
data: seq[byte]
|
data: seq[byte]
|
||||||
|
|
||||||
|
@ -61,10 +61,10 @@ proc readMsg*(conn: Connection): Future[Msg] {.async, gcsafe.} =
|
||||||
trace "read data", data = data.len
|
trace "read data", data = data.len
|
||||||
|
|
||||||
let header = headerVarint
|
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,
|
proc writeMsg*(conn: Connection,
|
||||||
id: uint,
|
id: uint64,
|
||||||
msgType: MessageType,
|
msgType: MessageType,
|
||||||
data: seq[byte] = @[]) {.async, gcsafe.} =
|
data: seq[byte] = @[]) {.async, gcsafe.} =
|
||||||
trace "seding data over mplex", id,
|
trace "seding data over mplex", id,
|
||||||
|
@ -81,7 +81,7 @@ proc writeMsg*(conn: Connection,
|
||||||
trace "unable to send message", exc = exc.msg
|
trace "unable to send message", exc = exc.msg
|
||||||
|
|
||||||
proc writeMsg*(conn: Connection,
|
proc writeMsg*(conn: Connection,
|
||||||
id: uint,
|
id: uint64,
|
||||||
msgType: MessageType,
|
msgType: MessageType,
|
||||||
data: string) {.async, gcsafe.} =
|
data: string) {.async, gcsafe.} =
|
||||||
result = conn.writeMsg(id, msgType, cast[seq[byte]](data))
|
result = conn.writeMsg(id, msgType, cast[seq[byte]](data))
|
||||||
|
|
|
@ -21,7 +21,7 @@ logScope:
|
||||||
|
|
||||||
type
|
type
|
||||||
LPChannel* = ref object of BufferStream
|
LPChannel* = ref object of BufferStream
|
||||||
id*: uint
|
id*: uint64
|
||||||
name*: string
|
name*: string
|
||||||
conn*: Connection
|
conn*: Connection
|
||||||
initiator*: bool
|
initiator*: bool
|
||||||
|
@ -35,7 +35,7 @@ type
|
||||||
closeCode*: MessageType
|
closeCode*: MessageType
|
||||||
resetCode*: MessageType
|
resetCode*: MessageType
|
||||||
|
|
||||||
proc newChannel*(id: uint,
|
proc newChannel*(id: uint64,
|
||||||
conn: Connection,
|
conn: Connection,
|
||||||
initiator: bool,
|
initiator: bool,
|
||||||
name: string = "",
|
name: string = "",
|
||||||
|
|
|
@ -28,12 +28,12 @@ const DefaultRWTimeout = InfiniteDuration
|
||||||
|
|
||||||
type
|
type
|
||||||
Mplex* = ref object of Muxer
|
Mplex* = ref object of Muxer
|
||||||
remote*: Table[uint, LPChannel]
|
remote*: Table[uint64, LPChannel]
|
||||||
local*: Table[uint, LPChannel]
|
local*: Table[uint64, LPChannel]
|
||||||
currentId*: uint
|
currentId*: uint64
|
||||||
maxChannels*: uint
|
maxChannels*: uint64
|
||||||
|
|
||||||
proc getChannelList(m: Mplex, initiator: bool): var Table[uint, LPChannel] =
|
proc getChannelList(m: Mplex, initiator: bool): var Table[uint64, LPChannel] =
|
||||||
if initiator:
|
if initiator:
|
||||||
trace "picking local channels", initiator = initiator
|
trace "picking local channels", initiator = initiator
|
||||||
result = m.local
|
result = m.local
|
||||||
|
@ -43,7 +43,7 @@ proc getChannelList(m: Mplex, initiator: bool): var Table[uint, LPChannel] =
|
||||||
|
|
||||||
proc newStreamInternal*(m: Mplex,
|
proc newStreamInternal*(m: Mplex,
|
||||||
initiator: bool = true,
|
initiator: bool = true,
|
||||||
chanId: uint = 0,
|
chanId: uint64 = 0,
|
||||||
name: string = "",
|
name: string = "",
|
||||||
lazy: bool = false):
|
lazy: bool = false):
|
||||||
Future[LPChannel] {.async, gcsafe.} =
|
Future[LPChannel] {.async, gcsafe.} =
|
||||||
|
@ -134,8 +134,8 @@ proc newMplex*(conn: Connection,
|
||||||
new result
|
new result
|
||||||
result.connection = conn
|
result.connection = conn
|
||||||
result.maxChannels = maxChanns
|
result.maxChannels = maxChanns
|
||||||
result.remote = initTable[uint, LPChannel]()
|
result.remote = initTable[uint64, LPChannel]()
|
||||||
result.local = initTable[uint, LPChannel]()
|
result.local = initTable[uint64, LPChannel]()
|
||||||
|
|
||||||
let m = result
|
let m = result
|
||||||
conn.closeEvent.wait()
|
conn.closeEvent.wait()
|
||||||
|
|
Loading…
Reference in New Issue