0

I know that some RPC query exist to get informations like : system_properties system_chain system_chainType

But I would like to have all of them in a same custom call. How I can access to those informations ?

Thank you.

5
  • Can you clarify your question? You want to create a custom RPC which does those 3 queries at once?
    – Shawn Tabrizi
    Commented Apr 28, 2022 at 9:27
  • @ShawnTabrizi yes that's it. do you have a suggestion ?
    – cibou
    Commented Apr 29, 2022 at 6:06
  • You either need to make 3 RPC calls, or write your own custom RPC in Substrate which does all three at once. There is no "trick" here.
    – Shawn Tabrizi
    Commented Apr 29, 2022 at 6:51
  • yes that is exactly what I want to do : write my one custom RPC but I dont know how to get those substrate informations given by system_syncState or system_properties ?
    – cibou
    Commented May 1, 2022 at 19:16
  • @ShawnTabrizi do you have an idea ?
    – cibou
    Commented May 2, 2022 at 16:39

1 Answer 1

1

All of those RPCs can be found here: https://github.com/paritytech/substrate/blob/master/client/rpc/src/system/mod.rs

impl<B: traits::Block> SystemApi<B::Hash, <B::Header as HeaderT>::Number> for System<B> {

    // -- snip --

    fn system_properties(&self) -> Result<sc_chain_spec::Properties> {
        Ok(self.info.properties.clone())
    }

    // -- snip --

    fn system_sync_state(&self) -> Receiver<SyncState<<B::Header as HeaderT>::Number>> {
        let (tx, rx) = oneshot::channel();
        let _ = self.send_back.unbounded_send(Request::SyncState(tx));
        Receiver(rx)
    }

    // -- snip --
}

These are then implemented in the node's RPC configuration:

https://github.com/paritytech/substrate/blob/master/bin/node/rpc/src/lib.rs

io.extend_with(SystemApi::to_delegate(FullSystem::new(client.clone(), pool, deny_unsafe)));
4
  • What I dont understand is that we declare instantiate with pub fn new( info: SystemInfo, send_back: TracingUnboundedSender<Request<B>>, deny_unsafe: DenyUnsafe, ) -> Self { System { info, send_back, deny_unsafe } } and we pass client.clone() for info in FullSystem::new(client.clone()
    – cibou
    Commented Jul 11, 2022 at 8:25
  • What is the question? Do you want to open a new question?
    – Shawn Tabrizi
    Commented Jul 11, 2022 at 9:13
  • I opened a new one
    – cibou
    Commented Jul 11, 2022 at 13:11
  • this one : substrate.stackexchange.com/questions/3698/…
    – cibou
    Commented Jul 12, 2022 at 9:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.