atomicals / atomicals-electrumx

Electrumx Atomicals Indexer Server
MIT License
187 stars 55 forks source link

When a block index is completed, push an index completion event to the proxy #153

Closed iota9star closed 7 months ago

iota9star commented 7 months ago

The data in the index is updated only after indexing a block, and before indexing a new block, all data remains unchanged. Implementing a caching layer in the proxy can significantly reduce requests reaching the indexer, thereby enhancing system performance.

If a completion event is sent to the proxy after indexing is complete, the proxy can clear the cache upon receiving the event. This enables real-time updates to the data.

AlexV525 commented 7 months ago

You can subscribe to the block notification by requesting blockchain.headers.subscribe. The session manager will notify every session with the message that the block has been indexed.

{
  "jsonrpc": "2.0",
  "method": "blockchain.headers.subscribe",
  "params": [
    {
      "hex": "00400020fae1aceb1dbb35b1ac1fa03986e1c85d0d742fe2b77878941500000000000000f2948fb0d72d63454a5ad073609a4cec0e384f7de729a4db2358dd4bde488df773ba0366434e2c19807dad2a",
      "height":2583779
    }
  ]
}