From d30dce9d537d4f31bd2e3920e640fe7bbe56c5ca Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Wed, 12 Sep 2018 18:28:38 +0300 Subject: [PATCH] Fix compilation issues when using peer.networkState --- eth_p2p.nim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/eth_p2p.nim b/eth_p2p.nim index 48ea9d6..f0ef7d7 100644 --- a/eth_p2p.nim +++ b/eth_p2p.nim @@ -599,6 +599,7 @@ proc getNetworkState(peer: Peer, proto: ProtocolInfo): RootRef = template networkState*(connection: Peer, Protocol: type): untyped = ## Returns the network state object of a particular protocol for a ## particular connection. + bind getNetworkState cast[ref Protocol.NetworkState](connection.getNetworkState(Protocol.protocolInfo)) proc initProtocolState*[T](state: var T, x: Peer|EthereumNode) = discard @@ -671,6 +672,7 @@ macro rlpxProtocol*(protoIdentifier: untyped, startList = bindSym "startList" writeMsgId = bindSym "writeMsgId" getState = bindSym "getState" + getNetworkState = bindSym "getNetworkState" perPeerMsgId = bindSym "perPeerMsgId" linkSendFutureToResult = bindSym "linkSendFutureToResult" @@ -700,7 +702,7 @@ macro rlpxProtocol*(protoIdentifier: untyped, if networkStateType != nil: var networkStateAccessor = quote: template networkState(p: `Peer`): ref `networkStateType` = - cast[ref `networkStateType`](p.getNetworkState(`protocol`)) + cast[ref `networkStateType`](`getNetworkState`(p, `protocol`)) userHandlerProc.body.insert 0, networkStateAccessor