Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ func NewPersistent(
// WAL journal mode, disable sync on write, increase cache size to 50MB (from 2MB)
metadataConnOpts := "_pragma=journal_mode(WAL)&_pragma=sync(OFF)&_pragma=cache_size(-50000)"
metadataDb, err := gorm.Open(
sqlite.Open(fmt.Sprintf("file:%s?%s", metadataDbPath, metadataConnOpts)),
sqlite.Open(
fmt.Sprintf("file:%s?%s", metadataDbPath, metadataConnOpts),
),
&gorm.Config{
Logger: gormlogger.Discard,
},
Expand Down
10 changes: 8 additions & 2 deletions database/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ func (r *Rat) Scan(val any) error {
}
v, ok := val.(string)
if !ok {
return fmt.Errorf("value was not expected type, wanted string, got %T", val)
return fmt.Errorf(
"value was not expected type, wanted string, got %T",
val,
)
}
if _, ok := r.SetString(v); !ok {
return fmt.Errorf("failed to set big.Rat value from string: %s", v)
Expand All @@ -55,7 +58,10 @@ func (u Uint64) Value() (driver.Value, error) {
func (u *Uint64) Scan(val any) error {
v, ok := val.(string)
if !ok {
return fmt.Errorf("value was not expected type, wanted string, got %T", val)
return fmt.Errorf(
"value was not expected type, wanted string, got %T",
val,
)
}
tmpUint, err := strconv.ParseUint(v, 10, 64)
if err != nil {
Expand Down
23 changes: 18 additions & 5 deletions state/chainsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ func (ls *LedgerState) handleEventBlockfetch(evt event.Event) {
if err := ls.handleEventBlockfetchBatchDone(e); err != nil {
// TODO: actually handle this error
ls.config.Logger.Error(
fmt.Sprintf("ledger: failed to handle blockfetch batch done: %s", err),
fmt.Sprintf(
"ledger: failed to handle blockfetch batch done: %s",
err,
),
)
}
} else if e.Block != nil {
Expand Down Expand Up @@ -104,7 +107,10 @@ func (ls *LedgerState) handleEventChainsyncBlockHeader(e ChainsyncEvent) error {
ls.chainsyncBlockfetchBusy = false
ls.chainsyncBlockfetchWaiting = false
ls.config.Logger.Warn(
fmt.Sprintf("blockfetch operation timed out after %s", blockfetchBusyTimeout),
fmt.Sprintf(
"blockfetch operation timed out after %s",
blockfetchBusyTimeout,
),
"component",
"ledger",
)
Expand Down Expand Up @@ -180,7 +186,10 @@ func (ls *LedgerState) processBlockEvents() error {
return nil
}

func (ls *LedgerState) processBlockEvent(txn *database.Txn, e BlockfetchEvent) error {
func (ls *LedgerState) processBlockEvent(
txn *database.Txn,
e BlockfetchEvent,
) error {
tmpBlock := models.Block{
Slot: e.Point.Slot,
Hash: e.Point.Hash,
Expand All @@ -203,7 +212,9 @@ func (ls *LedgerState) processBlockEvent(txn *database.Txn, e BlockfetchEvent) e
}
}
// Create initial epoch record
epochSlotLength, epochLength, err := ls.currentEra.EpochLengthFunc(ls.config.CardanoNodeConfig)
epochSlotLength, epochLength, err := ls.currentEra.EpochLengthFunc(
ls.config.CardanoNodeConfig,
)
if err != nil {
return err
}
Expand Down Expand Up @@ -233,7 +244,9 @@ func (ls *LedgerState) processBlockEvent(txn *database.Txn, e BlockfetchEvent) e
return err
}
// Create next epoch record
epochSlotLength, epochLength, err := ls.currentEra.EpochLengthFunc(ls.config.CardanoNodeConfig)
epochSlotLength, epochLength, err := ls.currentEra.EpochLengthFunc(
ls.config.CardanoNodeConfig,
)
if err != nil {
return err
}
Expand Down
4 changes: 3 additions & 1 deletion state/eras/byron.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ var ByronEraDesc = EraDesc{
EpochLengthFunc: EpochLengthByron,
}

func EpochLengthByron(nodeConfig *cardano.CardanoNodeConfig) (uint, uint, error) {
func EpochLengthByron(
nodeConfig *cardano.CardanoNodeConfig,
) (uint, uint, error) {
byronGenesis, err := nodeConfig.ByronGenesis()
if err != nil {
return 0, 0, err
Expand Down
4 changes: 3 additions & 1 deletion state/eras/shelley.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ func HardForkShelley(
return ret, nil
}

func EpochLengthShelley(nodeConfig *cardano.CardanoNodeConfig) (uint, uint, error) {
func EpochLengthShelley(
nodeConfig *cardano.CardanoNodeConfig,
) (uint, uint, error) {
shelleyGenesis, err := nodeConfig.ShelleyGenesis()
if err != nil {
return 0, 0, err
Expand Down
17 changes: 14 additions & 3 deletions state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,12 @@ func (ls *LedgerState) rollback(point ocommon.Point) error {
return nil
}

func (ls *LedgerState) transitionToEra(txn *database.Txn, nextEraId uint, startEpoch uint, addedSlot uint64) error {
func (ls *LedgerState) transitionToEra(
txn *database.Txn,
nextEraId uint,
startEpoch uint,
addedSlot uint64,
) error {
nextEra := eras.Eras[nextEraId]
if nextEra.HardForkFunc != nil {
// Perform hard fork
Expand Down Expand Up @@ -377,7 +382,11 @@ func (ls *LedgerState) transitionToEra(txn *database.Txn, nextEraId uint, startE
return nil
}

func (ls *LedgerState) applyPParamUpdates(txn *database.Txn, currentEpoch uint, addedSlot uint64) error {
func (ls *LedgerState) applyPParamUpdates(
txn *database.Txn,
currentEpoch uint,
addedSlot uint64,
) error {
// Check for pparam updates that apply at the end of the epoch
var pparamUpdates []models.PParamUpdate
result := txn.Metadata().
Expand Down Expand Up @@ -568,7 +577,9 @@ func (ls *LedgerState) loadTip() error {
// Update metrics
ls.metrics.blockNum.Set(float64(ls.currentTip.BlockNumber))
ls.metrics.slotNum.Set(float64(ls.currentTip.Point.Slot))
ls.metrics.slotInEpoch.Set(float64(ls.currentTip.Point.Slot - ls.currentEpoch.StartSlot))
ls.metrics.slotInEpoch.Set(
float64(ls.currentTip.Point.Slot - ls.currentEpoch.StartSlot),
)
return nil
}

Expand Down