Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
fix logging and a test
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhorsey committed Sep 28, 2023
1 parent f155300 commit 560b7e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions prover/capacity_manager/capacity_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (m *CapacityManager) ReleaseOneCapacity(blockID uint64) (uint64, bool) {
if _, ok := m.capacity[blockID]; !ok {
log.Info("Can not release capacity",
"blockID", blockID,
"currentCapacity", len(m.capacity),
"currentCapacity", m.maxCapacity-uint64(len(m.capacity)),
"maxCapacity", m.maxCapacity)
return uint64(len(m.capacity)), false
}
Expand All @@ -62,13 +62,17 @@ func (m *CapacityManager) TakeOneCapacity(blockID uint64) (uint64, bool) {
defer m.mutex.Unlock()

if len(m.capacity) == int(m.maxCapacity) {
log.Info("Could not take one capacity", "blockID", blockID, "capacity", len(m.capacity))
log.Info("Could not take one capacity",
"blockID", blockID,
"currentCapacity", m.maxCapacity-uint64(len(m.capacity)))
return 0, false
}

m.capacity[blockID] = true

log.Info("Took one capacity", "blockID", blockID, "capacityAfterTaking", len(m.capacity))
log.Info("Took one capacity",
"blockID", blockID,
"capacityAfterTaking", m.maxCapacity-uint64(len(m.capacity)))

return m.maxCapacity - uint64((len(m.capacity))), true
}
Expand All @@ -82,7 +86,9 @@ func (m *CapacityManager) TakeOneTempCapacity() (uint64, bool) {
m.clearExpiredTempCapacities()

if len(m.capacity)+len(m.tempCapacity) >= int(m.maxCapacity) {
log.Info("Could not take one temp capacity", "capacity", len(m.capacity), "tempCapacity", len(m.tempCapacity))
log.Info("Could not take one temp capacity",
"capacity", m.maxCapacity-uint64(len(m.capacity)),
"tempCapacity", len(m.tempCapacity))
return 0, false
}

Expand Down
1 change: 1 addition & 0 deletions prover/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ func (s *ProverTestSuite) SetupApp() *cli.App {
&cli.Uint64Flag{Name: flags.ProverCapacity.Name},
&cli.Uint64Flag{Name: flags.MinProofFee.Name},
&cli.Uint64Flag{Name: flags.ProveBlockTxGasLimit.Name},
&cli.DurationFlag{Name: flags.TempCapacityExpiresAt.Name},
}
app.Action = func(ctx *cli.Context) error {
_, err := NewConfigFromCliContext(ctx)
Expand Down

0 comments on commit 560b7e6

Please sign in to comment.