Closed trajan0x closed 1 week ago
To cap the TX count in chainConfirmQueue
, modify the function in ethergo/submitter/queue.go
as follows:
func (t *txSubmitterImpl) chainConfirmQueue(parentCtx context.Context, chainID *big.Int, txes []db.TX) (err error) {
ctx, span := t.metrics.Tracer().Start(parentCtx, "submitter.chainConfirmQueue")
defer func() {
metrics.EndSpanWithErr(span, err)
}()
chainClient, err := t.fetcher.GetClient(ctx, chainID)
if err != nil {
return fmt.Errorf("could not get client: %w", err)
}
nonceMap := groupTxesByNonce(txes)
const maxBatchSize = 1000 // Set the maximum batch size
for nonce := range nonceMap {
for i := 0; i < len(nonceMap[nonce]); i += maxBatchSize {
end := i + maxBatchSize
if end > len(nonceMap[nonce]) {
end = len(nonceMap[nonce])
}
batch := nonceMap[nonce][i:end]
err = t.checkAndSetConfirmation(ctx, chainClient, batch)
if err != nil {
return fmt.Errorf("could not check and set confirmation: %w", err)
}
}
}
return nil
}
see thhis single batch w/ 9,800 receipt requests: