loopdb: make new loopdb package to house persistent storage

This commit is contained in:
Olaoluwa Osuntokun 2019-03-06 18:19:57 -08:00
parent 74cf29a9cf
commit cdcb9f8345
12 changed files with 589 additions and 442 deletions

27
loopdb/interface.go Normal file
View file

@ -0,0 +1,27 @@
package loopdb
import (
"time"
"github.com/lightningnetwork/lnd/lntypes"
)
// SwapStore is the priamry database interface used by the loopd system. It
// houses informatino for all pending completed/failed swaps.
type SwapStore interface {
// FetchUnchargeSwaps returns all swaps currently in the store.
FetchUnchargeSwaps() ([]*PersistentUncharge, error)
// CreateUncharge adds an initiated swap to the store.
CreateUncharge(hash lntypes.Hash, swap *UnchargeContract) error
// UpdateUncharge stores a swap updateUncharge. This appends to the
// event log for a particular swap as it goes through the various
// stages in its lifetime.
UpdateUncharge(hash lntypes.Hash, time time.Time, state SwapState) error
// Close closes the underlying database.
Close() error
}
// TODO(roasbeef): back up method in interface?