Review synchronizer, rearange some stuff, add notes and TODOs.

This commit is contained in:
Eduard S
2020-09-18 18:17:00 +02:00
parent d3f6da22ed
commit 9f83fcf520
8 changed files with 171 additions and 145 deletions

View File

@@ -14,6 +14,8 @@ import (
"github.com/russross/meddler"
)
// TODO(Edu): Document here how HistoryDB is kept consistent
// HistoryDB persist the historic of the rollup
type HistoryDB struct {
db *sqlx.DB
@@ -129,9 +131,9 @@ func (hdb *HistoryDB) GetLastBatchNum() (common.BatchNum, error) {
// GetLastL1TxsNum returns the greatest ForgeL1TxsNum in the DB. If there's no
// batch in the DB (nil, nil) is returned.
func (hdb *HistoryDB) GetLastL1TxsNum() (*uint32, error) {
func (hdb *HistoryDB) GetLastL1TxsNum() (*int64, error) {
row := hdb.db.QueryRow("SELECT MAX(forge_l1_txs_num) FROM batch;")
lastL1TxsNum := new(uint32)
lastL1TxsNum := new(int64)
return lastL1TxsNum, row.Scan(&lastL1TxsNum)
}

View File

@@ -17,6 +17,8 @@ import (
"github.com/russross/meddler"
)
// TODO(Edu): Check DB consistency while there's concurrent use from Coordinator/TxSelector & API
// L2DB stores L2 txs and authorization registers received by the coordinator and keeps them until they are no longer relevant
// due to them being forged or invalid after a safety period
type L2DB struct {

View File

@@ -13,6 +13,8 @@ import (
"github.com/iden3/go-merkletree/db/pebble"
)
// TODO(Edu): Document here how StateDB is kept consistent
// ErrStateDBWithoutMT is used when a method that requires a MerkleTree is
// called in a StateDB that does not have a MerkleTree defined
var ErrStateDBWithoutMT = errors.New("Can not call method to use MerkleTree in a StateDB without MerkleTree")