paritytech / dotexporter

polkadot/substrate metrics exporter from rpc calls
GNU General Public License v3.0
6 stars 5 forks source link

dot_chain_block_number: Parse block number as scale encoded integer #4

Open mxinden opened 4 years ago

mxinden commented 4 years ago

As far as I can tell chain_getBlock returns the block height as a scale encoded integer. For all block number values within the range [0, 2^6) one can ignore the fact that it is SCALE encoded (given that it would be within the single byte mode) and can parse it as a HEX. Once one exceeds the before mentioned range one can not ignore the fact that it is scale encoded.

https://github.com/paritytech/dotexporter/blob/0ff8736291f4837faeb41223757bd33f24975418/dotexporter.py#L93-L97

mxinden commented 4 years ago

@gabreal any thoughts on this? Not sure it is worth fixing given that Substrate now exposes its metrics directly.

gabreal commented 4 years ago

Not sure whether the dotexporter will be useful in the future. I'm happy to implement it though if it's not taking huge efforts. Do you have an idea how this can be achieved in python?

mxinden commented 4 years ago

There is https://github.com/polkascan/py-scale-codec.