From 5051093207360d6fdc95f094bed27f7e8006ae7e Mon Sep 17 00:00:00 2001 From: sczembor Date: Mon, 23 Dec 2024 10:05:22 +0100 Subject: [PATCH] apply code review suggestions Signed-off-by: sczembor --- CHANGELOG.md | 17 ++++++++++++++++- README.md | 4 ++-- docs/db.md | 25 ++++++++----------------- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9f96ab..c3afdfb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ Usage: Change log entries are to be added to the Unreleased section and in one of the following subsections: Features, Breaking Changes, Bug Fixes. Example entry: -* [#](https://github.com/gonative-cc/relayer/pull/) +- [#](https://github.com/gonative-cc/relayer/pull/) --> # CHANGELOG @@ -21,6 +21,21 @@ Change log entries are to be added to the Unreleased section and in one of the f ### Features +- Added new functions in the `dal` package: + - `InsertIkaSignRequest(request IkaSignRequest)`: Inserts a new IKA sign request. + - `GetIkaSignRequestByID(id uint64)`: Retrieves an IKA sign request by ID. + - `GetPendingIkaSignRequests()`: Retrieves pending IKA sign requests (no final signature). + - `UpdateIkaSignRequestFinalSig(id uint64, finalSig Signature)`: Updates the final signature. + - `GetSignedIkaSignRequests()`: Retrieves signed IKA sign requests not yet broadcasted to Bitcoin. + - `InsertIkaTx(tx IkaTx)`: Inserts a new IKA transaction. + - `GetIkaTx(signRequestID uint64, ikaTxID string)`: Retrieves an IKA transaction by primary key. + - `InsertBitcoinTx(tx BitcoinTx)`: Inserts a new Bitcoin transaction. + - `GetBitcoinTx(signRequestID uint64, btcTxID []byte)`: Retrieves a Bitcoin transaction by primary key. + - `GetPendingBitcoinTxs()`: Retrieves Bitcoin transactions with "pending" status. + - `GetBroadcastedBitcoinTxs()`: Retrieves Bitcoin transactions with "broadcasted" status. + - `GetBroadcastedBitcoinTxsInfo()`: Retrieves info for "broadcasted" transactions without "confirmed" status. + - `UpdateBitcoinTxToConfirmed(id uint64, txID []byte)`: Updates Bitcoin transaction to "confirmed" and updates timestamp. + ### Breaking Changes ### Bug Fixes diff --git a/README.md b/README.md index 069962c..6048817 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,8 @@ A software that monitors and relayers: -- CometBFT blocks to update Native -> Ika light client -- Bitcoin blocks to update Bitcoin -> Native light client +- CometBFT blocks to update Native light client on Ika +- Bitcoin blocks to update Bitcoin light client on Native - Bitcoin SPV proofs to verify dWallet holdings - Native -> Bitcoin transaction relayer diff --git a/docs/db.md b/docs/db.md index d7955a1..84d0058 100644 --- a/docs/db.md +++ b/docs/db.md @@ -41,26 +41,17 @@ The relayer uses a SQLite database to store and manage transaction data. The dat ## Functions -The relayer interacts with the database using the following functions in the `dal` package: +The `dal` package handles all interactions with the database. The functions within this package can be grouped into the following categories: -### IKA Sign Requests +### IKA Sign Request -1. `InsertIkaSignRequest(request IkaSignRequest)`: Inserts a new IKA sign request into the `ika_sign_requests` table. -2. `GetIkaSignRequestByID(id uint64)`: Retrieves an IKA sign request by its ID. -3. `GetPendingIkaSignRequests()`: Retrieves all IKA sign requests that have not yet been successfully processed by IKA. This means the `final_sig` column in the `ika_sign_requests` table is NULL. -4. `UpdateIkaSignRequestFinalSig(id uint64, finalSig Signature)`: Updates the final signature of an IkaSignRequest in the database. -5. `GetSignedIkaSignRequests()`: Retrieves `IkaSignRequest`s that have been signed by IKA and have not yet been broadcasted to the Bitcoin network. +These functions manage the lifecycle of IKA sign requests within the `ika_sign_requests` table. -### IKA Transactions +### IKA Transaction -1. `InsertIkaTx(tx IkaTx)`: Inserts a new IKA transaction into the `ika_txs` table. -2. `GetIkaTx(signRequestID uint64, ikaTxID string)`: Retrieves an IKA transaction by its primary key. +These functions manage IKA transaction records in the `ika_txs` table. -### Bitcoin Transactions -1. `InsertBitcoinTx(tx BitcoinTx)`: Inserts a new Bitcoin transaction into the `bitcoin_txs` table. -2. `GetBitcoinTx(signRequestID uint64, btcTxID []byte)`: Retrieves a Bitcoin transaction by its primary key. -3. `GetPendingBitcoinTxs()`: Retrieves all Bitcoin transactions with a "pending" status from the database. -4. `GetBroadcastedBitcoinTxs()`: Retrieves all Bitcoin transactions with a "broadcasted" status from the database. -5. `GetBroadcastedBitcoinTxsInfo()`: Retrieves `BitcoinTxInfo` for transactions with "Broadcasted" status that do not have a "Confirmed" status. -6. `UpdateBitcoinTxToConfirmed(id uint64, txID []byte)`: Updates the Bitcoin transaction to `Confirmed` status and updates its timestamp. +### Bitcoin Transaction + +These functions manage Bitcoin transaction records in the `bitcoin_txs` table.