We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RPC module can be simplified:
Use map, instead of StreamExt::map
map
StreamExt::map
while let Some(sighash) = sighash_stream.next().await -> sighash_stream.map(|sh| operator.sign_with_tweak(sh))
Streamline RPC param/response encoding/decoding with a new trait type
trait RpcParse { fallible parsing from rpc type to domain types } trait RpcEncode { (in?)fallible encoding from domain type to rpc type } src/rpc/parsers/{entity_name}.rs: impl RpcParse for {entity_name}Input {} impl RpcEncode for … {} src/rpc/{entity_name}.rs: use parsers::{RpcParse, RpcEncode}; fn some_rpc_call(some_input_stream: Stream<Item = RpcInput) { let output_stream = actual_entity.some_call(some_input_stream.map(RpcParse::parse)); return Response::new(output_stream.map(RpcEncode::encode); } // Calls with initial args pub async fn with_initial_args(stream: impl Stream<RPCMsg>) -> Result<(initial_args, Stream<Item = Result>), BridgeErr> { let initial_args = stream.next().await?.parse_initial_args()?; (initial_args, stream.map(RPCParse::parse)) } trait RPCParse { type InitialArgs = DomainInitialArgs; type InnerMsg = DomainInnerMsg; fn parse_initial_args(&self) -> Result<Self::InitialArgs> { match self { InitialArgs => ..., _ => return Err("Expected initial args but got another msg") } } fn parse(self) -> Result<Self::InnerMsg> { ... } }
The text was updated successfully, but these errors were encountered:
ceyhunsen
No branches or pull requests
Proposal Description
RPC module can be simplified:
Use
map
, instead ofStreamExt::map
Streamline RPC param/response encoding/decoding with a new trait type
The text was updated successfully, but these errors were encountered: