dappforce/subsocial-js

Try to cache things required by Polkadot API when connecting to the chain

siman opened this issue · 0 comments

siman commented

Currently, Polkadot API spends over 5 seconds to connect to Substrate + retrieve initially required info about with several API requests from a chain and parse metadata. We need to speed up this setup process.

Jaco:

There is a lot of things it needs to do to get ready with the metadata.

it needs:

  • all the metadata
  • needs the genesis info
  • needs to latest info
  • needs the runtime versions
  • needs to tie all this together

You only know if things have not changed by retrieving what is on-chain. So you can skip metadata retrieval, for instance, you can pass the metadata.
(based on genesis hash and spec version)

you can pass the metadata if you want to use it that way. (Indexed by hash and version)

Code responsible for parsing / setting metadata:

https://github.com/polkadot-js/api/blob/master/packages/api/src/base/Init.ts#L171-L175