Skip to content

Commit

Permalink
fix(network): NoSessionId Error (nervosnetwork#33)
Browse files Browse the repository at this point in the history
Crate creep Context `with_value()` return value must be used.
  • Loading branch information
zeroqn committed Sep 25, 2019
1 parent c8404bb commit 4761d79
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 2 additions & 3 deletions core/network/src/reactor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ where
let SessionMessage { sid, msg: net_msg } = smsg;

let endpoint = net_msg.url.to_owned();
let mut ctx = Context::new();
ctx.set_session_id(sid);
let mut ctx = Context::new().set_session_id(sid);

let react = async move {
let endpoint = net_msg.url.parse::<Endpoint>()?;
Expand All @@ -75,7 +74,7 @@ where
EndpointScheme::RpcCall => {
let rpc_endpoint = RpcEndpoint::try_from(endpoint)?;

ctx.set_rpc_id(rpc_endpoint.rpc_id().value());
let ctx = ctx.set_rpc_id(rpc_endpoint.rpc_id().value());
handler.process(ctx, content).await?
}
EndpointScheme::RpcResponse => {
Expand Down
2 changes: 2 additions & 0 deletions core/network/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ impl NetworkContext for Context {
.ok_or_else(|| ErrorKind::NoSessionId.into())
}

#[must_use]
fn set_session_id(&mut self, sid: SessionId) -> Self {
self.with_value::<CtxSessionId>("session_id", CtxSessionId(sid))
}
Expand All @@ -67,6 +68,7 @@ impl NetworkContext for Context {
.ok_or_else(|| ErrorKind::NoRpcId.into())
}

#[must_use]
fn set_rpc_id(&mut self, rid: u64) -> Self {
self.with_value::<CtxRpcId>("rpc_id", CtxRpcId(rid))
}
Expand Down

0 comments on commit 4761d79

Please sign in to comment.