pinax-network / substreams

Substreams built by Pinax
Apache License 2.0
5 stars 2 forks source link

Add to Common for IBC lightproof DB #17

Closed DenisCarriere closed 1 year ago

DenisCarriere commented 1 year ago

To Add

Types

Data required

Code example consuming data

function processBlock(data){
    return rootDB.transaction(async () => {
      let block = JSON.parse(JSON.stringify(data.block, null, "  "));
      if (data.step === "STEP_IRREVERSIBLE") {
        lib = block.number;
        statusDB.put("lib", block.number);
      }
      else { //if STEP_NEW
        let date = (new Date(parseInt(block.header.timestamp.seconds)*1000)).toISOString().replace('Z', '');
        if (block.header.timestamp.nanos) date = date.replace('000', '500')
        statusDB.put("lastBlockTimestamp", date); 
      }
      const blockMerkle = block.blockrootMerkle;
      blockMerkle.activeNodes.forEach((node,index) => blockMerkle.activeNodes[index] = toHex(node) );
      var buffer = serialize(block.id, blockMerkle.activeNodes);
      blocksDB.put(block.number, asBinary(buffer));
    });
  }
DenisCarriere commented 1 year ago

Implemented

https://github.com/EOS-Nation/substreams-antelope/tree/develop/substreams/eosio.ibc

Antelope eosio.ibc Substream

Antelope eosio.ibc Lightproof block details.

Quickstart

$ substreams run -e eos.firehose.eosnation.io:9001 substreams.yaml map_lightproof --stop-block 10000 --production-mode

Graph

graph TD;
  map_lightproof[map: map_lightproof]
  sf.antelope.type.v2.Block[source: sf.antelope.type.v2.Block] --> map_lightproof

Modules

Name: map_lightproof
Initial block: 2
Kind: map
Output Type: proto:antelope.eosio.ibc.v1.Lightproof
Hash: 527e87617c2f55541a50ac2ee08377ac721479fc