mirror of
https://github.com/aljazceru/ark.git
synced 2026-02-23 12:12:49 +01:00
Implements SQLite repositories (#180)
* add sqlite db * add .vscode to gitignore * add vtxo repo * add sqlite repos implementations * add sqlite in db/service * update go.mod * fix sqlite * move sqlite tests to service_test.go + fixes * integration tests using sqlite + properly close statements * implement GetRoundsIds * add "tx" table to store forfeits, connectors and congestion trees * add db max conn = 1 * upsert VTXO + fix onboarding * remove json tags * Fixes * Fix * fix lint * fix config.go * Fix rm config & open db only once * Update makefile --------- Co-authored-by: altafan <18440657+altafan@users.noreply.github.com>
This commit is contained in:
@@ -267,10 +267,13 @@ func (s *service) Onboard(
|
||||
|
||||
log.Debugf("broadcasted boarding tx %s", txid)
|
||||
|
||||
s.onboardingCh <- onboarding{
|
||||
tx: boardingTx,
|
||||
congestionTree: congestionTree,
|
||||
userPubkey: userPubkey,
|
||||
sharedOutputScript := hex.EncodeToString(extracted.Outputs[0].Script)
|
||||
if _, ok := s.trustedOnboardingScripts[sharedOutputScript]; !ok {
|
||||
s.onboardingCh <- onboarding{
|
||||
tx: boardingTx,
|
||||
congestionTree: congestionTree,
|
||||
userPubkey: userPubkey,
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -594,7 +597,7 @@ func (s *service) listenToScannerNotifications() {
|
||||
continue
|
||||
}
|
||||
|
||||
if _, err := s.repoManager.Vtxos().RedeemVtxos(ctx, []domain.VtxoKey{vtxo.VtxoKey}); err != nil {
|
||||
if err := s.repoManager.Vtxos().RedeemVtxos(ctx, []domain.VtxoKey{vtxo.VtxoKey}); err != nil {
|
||||
log.WithError(err).Warn("failed to redeem vtxos, retrying...")
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import (
|
||||
type RoundEventRepository interface {
|
||||
Save(ctx context.Context, id string, events ...RoundEvent) (*Round, error)
|
||||
Load(ctx context.Context, id string) (*Round, error)
|
||||
RegisterEventsHandler(func(*Round))
|
||||
Close()
|
||||
}
|
||||
|
||||
type RoundRepository interface {
|
||||
@@ -17,16 +19,18 @@ type RoundRepository interface {
|
||||
GetSweepableRounds(ctx context.Context) ([]Round, error)
|
||||
GetRoundsIds(ctx context.Context, startedAfter int64, startedBefore int64) ([]string, error)
|
||||
GetSweptRounds(ctx context.Context) ([]Round, error)
|
||||
Close()
|
||||
}
|
||||
|
||||
type VtxoRepository interface {
|
||||
AddVtxos(ctx context.Context, vtxos []Vtxo) error
|
||||
SpendVtxos(ctx context.Context, vtxos []VtxoKey, txid string) error
|
||||
RedeemVtxos(ctx context.Context, vtxos []VtxoKey) ([]Vtxo, error)
|
||||
RedeemVtxos(ctx context.Context, vtxos []VtxoKey) error
|
||||
GetVtxos(ctx context.Context, vtxos []VtxoKey) ([]Vtxo, error)
|
||||
GetVtxosForRound(ctx context.Context, txid string) ([]Vtxo, error)
|
||||
SweepVtxos(ctx context.Context, vtxos []VtxoKey) error
|
||||
GetAllVtxos(ctx context.Context, pubkey string) ([]Vtxo, []Vtxo, error)
|
||||
GetAllSweepableVtxos(ctx context.Context) ([]Vtxo, error)
|
||||
UpdateExpireAt(ctx context.Context, vtxos []VtxoKey, expireAt int64) error
|
||||
Close()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user