Skip to content

[feature]: Add block_header SQL Table #1481

Open
@ffranr

Description

@ffranr

The chain_txns table currently stores block_hash and block_height, but not timestamp, which the TW team needs to improve UI/UX. They're currently doing an external lookup to get it. tapd should retain this information instead of discarding it, as it currently does.

Proposed Changes

  • Create a new block_header table (integer primary key for re-org simplicity):
    CREATE TABLE block_header (
        id INTEGER PRIMARY KEY,
        hash BLOB UNIQUE NOT NULL,
        height INTEGER NOT NULL,
        timestamp TIMESTAMP NOT NULL
    );
  • Update chain_txns to reference block_header(id).

Notes

  • Using id as the primary key allows multiple blocks with the same height (re-orgs).
  • timestamp can be NULL by default; tapd will populate for new entries, simplifies migration and is fine for out use-case.

Follow-Up Work

  • Add and populate the block header timestamp field in asset.ChainAsset.
  • Ensure the new asset.ChainAsset field is included in the relevant RPC response messages.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions