apibara/dna

Add rpc method to retrieve indexing/chain status

fracek opened this issue · 2 comments

Is your feature request related to a problem? Please describe.
Sometimes we need to know what's the latest available block number/hash. We can use the JSON-RPC provider to do that, but there is always the possibility that the Apibara DNA node and the provider node are not exactly at the same block.

Describe the solution you'd like
We should add a Status method to the rpc that returns the block syncing status, together with the cursors of the current finalized and accepted blocks.

service Stream {
  rpc Status(StatusRequest) returns (StatusResponse);
}

message StatusRequest {
}

message StatusResponse {
  // Optional because the chain may be so new that no block has been finalized. For example, devnets.
  optional Cursor finalized = 1;
  Cursor latest = 2;
  IngestionStatus status = 3;
}

enum IngestionStatus {
  INGESTION_STATUS_UNKNOWN = 0;
  INGESTION_STATUS_SYNCING = 1;
  INGESTION_STATUS_SYNCED = 2;
}

Happy to take this

Done in #237