Skip to content

Commit 04ddb7b

Browse files
committed
(to squash) re-introduce the check in addSweeps
1 parent 5e5b177 commit 04ddb7b

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

sweepbatcher/sweep_batch.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -602,15 +602,15 @@ func (b *batch) addSweeps(ctx context.Context, sweeps []*sweep) (bool, error) {
602602
}
603603

604604
// Track if there is a presigned and a regular sweep.
605-
var hasPresigned, hasRegular bool
605+
var addingPresigned, addingRegular bool
606606
for _, s := range sweeps {
607607
if s.presigned {
608-
hasPresigned = true
608+
addingPresigned = true
609609
} else {
610-
hasRegular = true
610+
addingRegular = true
611611
}
612612
}
613-
if hasPresigned && hasRegular {
613+
if addingPresigned && addingRegular {
614614
b.Warnf("There are presigned and regular sweeps in the group")
615615

616616
return false, nil
@@ -619,7 +619,7 @@ func (b *batch) addSweeps(ctx context.Context, sweeps []*sweep) (bool, error) {
619619
// If presigned mode is enabled, we should first presign the new version
620620
// of batch transaction. Also ensure that all the sweeps in the batch
621621
// use the same mode (presigned or regular).
622-
if hasPresigned {
622+
if addingPresigned {
623623
// Ensure that all the sweeps in the batch use presigned mode.
624624
for _, s := range b.sweeps {
625625
if !s.presigned {
@@ -662,6 +662,18 @@ func (b *batch) addSweeps(ctx context.Context, sweeps []*sweep) (bool, error) {
662662
" this input: %v",
663663
sweeps[0].swapHash[:6], err)
664664

665+
return false, nil
666+
}
667+
}
668+
} else {
669+
// Ensure that all the sweeps in the batch don't use presigned.
670+
for _, s := range b.sweeps {
671+
if s.presigned {
672+
b.Warnf("failed to add a non-presigned sweep "+
673+
"%x to the batch, because the batch "+
674+
"has presigned sweep %x",
675+
sweeps[0].swapHash[:6], s.swapHash[:6])
676+
665677
return false, nil
666678
}
667679
}

0 commit comments

Comments
 (0)