mirror of https://github.com/status-im/nim-eth.git
Minor adjustments in utp_discv5_protocol (#459)
- Move SocketConfig parameter location - Reuse rng from disc5 protocol - add exports - Some whitespace clean-up
This commit is contained in:
parent
0f18272315
commit
26ab9b078e
|
@ -13,7 +13,7 @@ import
|
|||
./utp_router,
|
||||
../keys
|
||||
|
||||
export utp_router
|
||||
export utp_router, protocol
|
||||
|
||||
type UtpDiscv5Protocol* = ref object of TalkProtocol
|
||||
prot: protocol.Protocol
|
||||
|
@ -66,16 +66,15 @@ proc new*(
|
|||
p: protocol.Protocol,
|
||||
subProtocolName: seq[byte],
|
||||
acceptConnectionCb: AcceptConnectionCallback[Node],
|
||||
socketConfig: SocketConfig = SocketConfig.init(),
|
||||
allowConnectionCb: AllowConnectionCallback[Node] = nil,
|
||||
rng = newRng()): UtpDiscv5Protocol =
|
||||
socketConfig: SocketConfig = SocketConfig.init()): UtpDiscv5Protocol =
|
||||
doAssert(not(isNil(acceptConnectionCb)))
|
||||
|
||||
let router = UtpRouter[Node].new(
|
||||
acceptConnectionCb,
|
||||
allowConnectionCb,
|
||||
socketConfig,
|
||||
rng
|
||||
p.rng
|
||||
)
|
||||
router.sendCb = initSendCallback(p, subProtocolName)
|
||||
|
||||
|
|
|
@ -113,8 +113,8 @@ proc new*[A](
|
|||
rng = newRng()): UtpRouter[A] =
|
||||
UtpRouter[A].new(acceptConnectionCb, nil, socketConfig, rng)
|
||||
|
||||
# There are different possiblites how connection was established, and we need to
|
||||
# check every case
|
||||
# There are different possibilities on how the connection got established, need
|
||||
# to check every case.
|
||||
proc getSocketOnReset[A](r: UtpRouter[A], sender: A, id: uint16): Option[UtpSocket[A]] =
|
||||
# id is our recv id
|
||||
let recvKey = UtpSocketKey[A].init(sender, id)
|
||||
|
|
|
@ -145,14 +145,14 @@ procSuite "Utp protocol over discovery v5 tests":
|
|||
node1,
|
||||
utpProtId,
|
||||
registerIncomingSocketCallback(queue),
|
||||
SocketConfig.init(lowSynTimeout))
|
||||
socketConfig = SocketConfig.init(lowSynTimeout))
|
||||
utp2 =
|
||||
UtpDiscv5Protocol.new(
|
||||
node2,
|
||||
utpProtId,
|
||||
registerIncomingSocketCallback(queue),
|
||||
SocketConfig.init(),
|
||||
allowOneIdCallback(allowedId))
|
||||
allowOneIdCallback(allowedId),
|
||||
SocketConfig.init())
|
||||
|
||||
# nodes must know about each other
|
||||
check:
|
||||
|
@ -191,7 +191,7 @@ procSuite "Utp protocol over discovery v5 tests":
|
|||
node2,
|
||||
utpProtId,
|
||||
registerIncomingSocketCallback(queue),
|
||||
SocketConfig.init(incomingSocketReceiveTimeout = none[Duration]())
|
||||
socketConfig = SocketConfig.init(incomingSocketReceiveTimeout = none[Duration]())
|
||||
)
|
||||
|
||||
# nodes must know about each other
|
||||
|
|
Loading…
Reference in New Issue