mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 19:36:44 +01:00
Sync ForgerCommitment and use it in coord
Previously the coordinator was erroneously using Slot.BatchesLen to determine when anyone can forge. The correct behaviour is implmenented with the boolean flag `ForgerCommitment`, that is set to true only when there's a batch before the deadline within a slot. Delete Slot.BatchesLen, and the synchronization code of this value from the Synchronizer, as this is not needed
This commit is contained in:
@@ -293,11 +293,15 @@ func (hdb *HistoryDB) GetBatches(from, to common.BatchNum) ([]common.Batch, erro
|
||||
return db.SlicePtrsToSlice(batches).([]common.Batch), tracerr.Wrap(err)
|
||||
}
|
||||
|
||||
// GetBatchesLen retrieve number of batches from the DB, given a slotNum
|
||||
func (hdb *HistoryDB) GetBatchesLen(slotNum int64) (int, error) {
|
||||
row := hdb.db.QueryRow("SELECT COUNT(*) FROM batch WHERE slot_num = $1;", slotNum)
|
||||
var batchesLen int
|
||||
return batchesLen, tracerr.Wrap(row.Scan(&batchesLen))
|
||||
// GetFirstBatchBlockNumBySlot returns the ethereum block number of the first
|
||||
// batch within a slot
|
||||
func (hdb *HistoryDB) GetFirstBatchBlockNumBySlot(slotNum int64) (int64, error) {
|
||||
row := hdb.db.QueryRow(
|
||||
`SELECT eth_block_num FROM batch
|
||||
WHERE slot_num = $1 ORDER BY batch_num ASC LIMIT 1;`, slotNum,
|
||||
)
|
||||
var blockNum int64
|
||||
return blockNum, tracerr.Wrap(row.Scan(&blockNum))
|
||||
}
|
||||
|
||||
// GetLastBatchNum returns the BatchNum of the latest forged batch
|
||||
|
||||
Reference in New Issue
Block a user