NewCommitBatcher now has an additional

error return to deal with errors arising from fetching the sealing config.
This commit is contained in:
aarshkshah1992
2024-07-16 12:26:53 +04:00
committed by Aarsh Shah
parent a2b963a675
commit 7635d55412
3 changed files with 19 additions and 15 deletions

View File

@ -83,7 +83,7 @@ type CommitBatcher struct {
lk sync.Mutex
}
func NewCommitBatcher(mctx context.Context, maddr address.Address, api CommitBatcherApi, addrSel AddressSelector, feeCfg config.MinerFeeConfig, getConfig dtypes.GetSealingConfigFunc, prov storiface.Prover) *CommitBatcher {
func NewCommitBatcher(mctx context.Context, maddr address.Address, api CommitBatcherApi, addrSel AddressSelector, feeCfg config.MinerFeeConfig, getConfig dtypes.GetSealingConfigFunc, prov storiface.Prover) (*CommitBatcher, error) {
b := &CommitBatcher{
api: api,
maddr: maddr,
@ -103,20 +103,20 @@ func NewCommitBatcher(mctx context.Context, maddr address.Address, api CommitBat
stopped: make(chan struct{}),
}
go b.run()
return b
}
func (b *CommitBatcher) run() {
var forceRes chan []sealiface.CommitBatchRes
var lastMsg []sealiface.CommitBatchRes
cfg, err := b.getConfig()
if err != nil {
panic(err)
return nil, err
}
go b.run(cfg)
return b, nil
}
func (b *CommitBatcher) run(cfg sealiface.Config) {
var forceRes chan []sealiface.CommitBatchRes
var lastMsg []sealiface.CommitBatchRes
timer := time.NewTimer(b.batchWait(cfg.CommitBatchWait, cfg.CommitBatchSlack))
for {
if forceRes != nil {