chaingraph icon indicating copy to clipboard operation
chaingraph copied to clipboard

`node.latest_block`

Open bitjson opened this issue 4 years ago • 0 comments

It would be useful for each node to have a latest_block field for holding their latest node_block. This should be effectively the same as latest_block in this query:

{
  node {
    name
    user_agent
    latest_block: accepted_blocks(
      limit: 1
      order_by: { block_internal_id: desc }
    ) {
      block {
        hash
        height
      }
    }
  }
}

This would be the best way to fetch the data for "confirmations" for a block or transaction. E.g.:

{
  transaction(
    where: {
      hash: {
        _eq: "\\x01234..."
      }
    }
  ) {
    block_inclusions {
      block {
        hash
        height
        accepted_by {
          node {
            name
            user_agent
            latest_block {
              block {
                height
              }
            }
          }
        }
      }
    }
  }
}

One entry per block per node, since the same transaction would produce different confirmation counts if it was either confirmed in different (competing) blocks or occurred before a chain split (after which the transaction has a different number of confirmations on each side of the split).

After implementing, the Monitor Sync Status query should be updated to use latest_block on https://chaingraph.cash/.

bitjson avatar Nov 24 '21 03:11 bitjson