Skip to content

Commit

Permalink
apply code review suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: sczembor <[email protected]>
  • Loading branch information
sczembor committed Dec 23, 2024
1 parent f0bb685 commit 5051093
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
* [#<PR-number>](https://github.com/gonative-cc/relayer/pull/<PR-number>) <description>
- [#<PR-number>](https://github.com/gonative-cc/relayer/pull/<PR-number>) <description>
-->

# CHANGELOG
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
25 changes: 8 additions & 17 deletions docs/db.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit 5051093

Please sign in to comment.