-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
1,019 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package base | ||
|
||
import ( | ||
"github.com/synapsecns/sanguine/core/metrics" | ||
submitterDB "github.com/synapsecns/sanguine/ethergo/submitter/db" | ||
"github.com/synapsecns/sanguine/ethergo/submitter/db/txdb" | ||
"gorm.io/gorm" | ||
) | ||
|
||
// Store is a store that implements an underlying gorm db. | ||
type Store struct { | ||
db *gorm.DB | ||
metrics metrics.Handler | ||
submitterStore submitterDB.Service | ||
} | ||
|
||
// NewStore creates a new store. | ||
func NewStore(db *gorm.DB, metrics metrics.Handler) *Store { | ||
txDB := txdb.NewTXStore(db, metrics) | ||
return &Store{db: db, metrics: metrics, submitterStore: txDB} | ||
} | ||
|
||
// DB gets the database object for mutation outside of the lib. | ||
func (s Store) DB() *gorm.DB { | ||
return s.db | ||
} | ||
|
||
// SubmitterDB gets the submitter database object for mutation outside of the lib. | ||
func (s Store) SubmitterDB() submitterDB.Service { | ||
return s.submitterStore | ||
} | ||
|
||
// GetAllModels gets all models to migrate. | ||
// see: https://medium.com/@SaifAbid/slice-interfaces-8c78f8b6345d for an explanation of why we can't do this at initialization time | ||
func GetAllModels() (allModels []interface{}) { | ||
allModels = append(allModels, txdb.GetAllModels()...) | ||
return allModels | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Package base contains the base sql implementation | ||
package base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Package sql provides a common interface for starting sql-lite databases | ||
package sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Package mysql contains a mysql db | ||
package mysql |
Oops, something went wrong.