-
Notifications
You must be signed in to change notification settings - Fork 120
staticaddr: persist withdrawal info #938
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
aab693b
to
e22b2b2
Compare
Rebased. |
Rebased |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I think a quick sql store unit test would be nice
|
||
// SqlStore is the backing store for static address withdrawals. | ||
type SqlStore struct { | ||
baseDB *loopdb.BaseDB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this exposes the full queries to this package, which IMO is not neccessary. as we usually define a Querier interface.
|
||
-- deposit_outpoints is a concatenated list of outpoints that are used for | ||
-- this withdrawal. The list has the format txid1:idx;txid2:idx;... | ||
deposit_outpoints TEXT NOT NULL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could it make sense to really sqlize this? and reference the db deposit id?
So add a table with:
ID, withdrawal_id REFRERNCES withdrawals.id(or tx_id), deposit_id REFERENCES(deposits.deposit_id)
I noticed we don't do the same in static loop ins, but it would allow for more interesting queries i feel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
} | ||
|
||
// CreateWithdrawal creates a static address withdrawal record in the database. | ||
func (s *SqlStore) CreateWithdrawal(ctx context.Context, tx *wire.MsgTx, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose adding a light unit test for future regressions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice feature, added a couple of comments/suggestions.
-- withdrawals stores finalized static address withdrawals. | ||
CREATE TABLE IF NOT EXISTS withdrawals ( | ||
-- id is the auto-incrementing primary key for a withdrawal. | ||
id INTEGER PRIMARY KEY, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be nice to add an initiated_at
column to this table, so that we can then filter on that on the cli too.
|
||
-- deposit_outpoints is a concatenated list of outpoints that are used for | ||
-- this withdrawal. The list has the format txid1:idx;txid2:idx;... | ||
deposit_outpoints TEXT NOT NULL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
|
||
-- confirmation_height is the block height at which the withdrawal was | ||
-- first confirmed. | ||
confirmation_height BIGINT NOT NULL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be allowed to be NULL
until the withdrawal confirms?
m.mu.Lock() | ||
delete(m.finalizedWithdrawalTxns, txHash) | ||
m.mu.Unlock() | ||
|
||
// Persist info about the finalized withdrawal. | ||
err = m.cfg.Store.CreateWithdrawal( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be nicer to add the withdrawal at the time it is requested then later on set it to confirmed.
} | ||
|
||
// CreateWithdrawal creates a static address withdrawal record in the database. | ||
func (s *SqlStore) CreateWithdrawal(ctx context.Context, tx *wire.MsgTx, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
addresses #936
sample output: