-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
33 changed files
with
1,080 additions
and
1,396 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,35 @@ | ||
package dbstorage | ||
|
||
import ( | ||
"context" | ||
"database/sql" | ||
|
||
"github.com/0xPolygon/cdk/db" | ||
) | ||
|
||
// DBStorage implements the Storage interface | ||
type DBStorage struct { | ||
DB *sql.DB | ||
} | ||
|
||
// NewDBStorage creates a new DBStorage instance | ||
func NewDBStorage(dbPath string) (*DBStorage, error) { | ||
db, err := db.NewSQLiteDB(dbPath) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &DBStorage{DB: db}, nil | ||
} | ||
|
||
func (d *DBStorage) BeginTx(ctx context.Context, options *sql.TxOptions) (db.Txer, error) { | ||
return db.NewTx(ctx, d.DB) | ||
} | ||
|
||
func (d *DBStorage) getExecQuerier(dbTx db.Txer) db.Querier { | ||
if dbTx == nil { | ||
return d.DB | ||
} | ||
|
||
return dbTx | ||
} |
Oops, something went wrong.