refactor: split reader and writer datagateway

This commit is contained in:
Gaze
2024-04-10 14:18:54 +07:00
parent c9df3ecd45
commit f5b3efe551

View File

@@ -15,10 +15,27 @@ type FlushData struct {
BlockHeight uint64
}
type RunesProcessorDataGateway interface {
type RunesDataGateway interface {
RunesReaderDataGateway
RunesWriterDataGateway
}
type RunesReaderDataGateway interface {
GetRunesBalancesAtOutPoint(ctx context.Context, outPoint wire.OutPoint) (map[runes.RuneId]uint128.Uint128, error)
GetRuneIdByRune(ctx context.Context, rune runes.Rune) (runes.RuneId, error)
GetRuneEntryByRuneId(ctx context.Context, runeId runes.RuneId) (*runes.RuneEntry, error)
FlushStates(ctx context.Context, data FlushData) error
}
type RunesWriterDataGateway interface {
// Begin starts a DB transaction. All write operations done after this call must call Commit() to persist the changes.
Begin(ctx context.Context) error
// Commit commits the DB transaction. All changes made after Begin() will be persisted.
Commit(ctx context.Context) error
// Rollback rolls back the DB transaction. All changes made after Begin() will be discarded.
Rollback(ctx context.Context) error
SetRuneEntry(ctx context.Context, entry *runes.RuneEntry) error
CreateRunesBalanceAtOutPoint(ctx context.Context, outPoint wire.OutPoint, balances map[runes.RuneId]uint128.Uint128) error
CreateRuneBalance(ctx context.Context, pkScript string, runeId runes.RuneId, blockHeight uint64, balance uint128.Uint128) error
UpdateLatestBlockHeight(ctx context.Context, blockHeight uint64) error
}