-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: store retries and discarded certificates on storage (configurable)
- Loading branch information
1 parent
521b968
commit 80d5f0a
Showing
10 changed files
with
113 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,35 @@ | ||
-- +migrate Down | ||
DROP TABLE IF EXISTS certificate_info; | ||
DROP TABLE IF EXISTS certificate_info_history; | ||
DROP TABLE IF EXISTS certificate_info_history; | ||
|
||
-- +migrate Up | ||
CREATE TABLE certificate_info ( | ||
height INTEGER NOT NULL, | ||
certificate_id VARCHAR NOT NULL PRIMARY KEY, | ||
retry_count INTEGER DEFAULT 0, | ||
certificate_id VARCHAR NOT NULL, | ||
status INTEGER NOT NULL, | ||
previous_local_exit_root VARCHAR , | ||
previous_local_exit_root VARCHAR, | ||
new_local_exit_root VARCHAR NOT NULL, | ||
from_block INTEGER NOT NULL, | ||
to_block INTEGER NOT NULL, | ||
created_at INTEGER NOT NULL, | ||
updated_at INTEGER NOT NULL, | ||
signed_certificate TEXT | ||
); | ||
signed_certificate TEXT, | ||
PRIMARY KEY (height) | ||
); | ||
|
||
CREATE TABLE certificate_info_history ( | ||
height INTEGER NOT NULL , | ||
retry_count INTEGER DEFAULT 0, | ||
certificate_id VARCHAR NOT NULL, | ||
status INTEGER NOT NULL, | ||
previous_local_exit_root VARCHAR, | ||
new_local_exit_root VARCHAR NOT NULL, | ||
from_block INTEGER NOT NULL, | ||
to_block INTEGER NOT NULL, | ||
created_at INTEGER NOT NULL, | ||
updated_at INTEGER NOT NULL, | ||
signed_certificate TEXT, | ||
PRIMARY KEY (height, retry_count) | ||
); |
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 |
---|---|---|
@@ -1,22 +1,24 @@ | ||
package migrations | ||
|
||
import ( | ||
"database/sql" | ||
_ "embed" | ||
|
||
"github.com/0xPolygon/cdk/db" | ||
"github.com/0xPolygon/cdk/db/types" | ||
"github.com/0xPolygon/cdk/log" | ||
) | ||
|
||
//go:embed 0001.sql | ||
var mig001 string | ||
|
||
func RunMigrations(dbPath string) error { | ||
func RunMigrations(logger *log.Logger, database *sql.DB) error { | ||
migrations := []types.Migration{ | ||
{ | ||
ID: "0001", | ||
SQL: mig001, | ||
}, | ||
} | ||
|
||
return db.RunMigrations(dbPath, migrations) | ||
return db.RunMigrationsDB(logger, database, migrations) | ||
} |
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
Oops, something went wrong.