contractcourt: offer second-level outputs at CSV-1
This commit moves the offering of second-level outputs one block earlier. The sweeper will check the required locktime and wait until it matures. This is needed so the second-level outputs can be aggregated properly.
This commit is contained in:
4 files changed
+77
-12
No files matched your search
+16
-2
@@ -652,7 +652,7 @@ func (s *UtxoSweeper) collector(blockEpochs <-chan *chainntnfs.BlockEpoch) {
|
||||
// failed, or excluded from the sweeper and return inputs that
|
||||
// are either new or has been published but failed back, which
|
||||
// will be retried again here.
|
||||
inputs := s.updateSweeperInputs()
|
||||
s.updateSweeperInputs()
|
||||
|
||||
select {
|
||||
// A new inputs is offered to the sweeper. We check to see if
|
||||
@@ -670,7 +670,7 @@ func (s *UtxoSweeper) collector(blockEpochs <-chan *chainntnfs.BlockEpoch) {
|
||||
// If this input is forced, we perform an sweep
|
||||
// immediately.
|
||||
if input.params.Force {
|
||||
inputs = s.updateSweeperInputs()
|
||||
inputs := s.updateSweeperInputs()
|
||||
s.sweepPendingInputs(inputs)
|
||||
}
|
||||
|
||||
@@ -716,6 +716,9 @@ func (s *UtxoSweeper) collector(blockEpochs <-chan *chainntnfs.BlockEpoch) {
|
||||
// Update the sweeper to the best height.
|
||||
s.currentHeight = epoch.Height
|
||||
|
||||
// Update the inputs with the latest height.
|
||||
inputs := s.updateSweeperInputs()
|
||||
|
||||
log.Debugf("Received new block: height=%v, attempt "+
|
||||
"sweeping %d inputs", epoch.Height, len(inputs))
|
||||
|
||||
@@ -1497,6 +1500,17 @@ func (s *UtxoSweeper) updateSweeperInputs() InputsMap {
|
||||
continue
|
||||
}
|
||||
|
||||
// If the input has a CSV that's not yet reached, we will skip
|
||||
// this input and wait for the expiry.
|
||||
locktime = input.BlocksToMaturity() + input.HeightHint()
|
||||
if s.currentHeight < int32(locktime)-1 {
|
||||
log.Infof("Skipping input %v due to CSV expiry=%v not "+
|
||||
"reached, current height is %v", op, locktime,
|
||||
s.currentHeight)
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
// If this input is new or has been failed to be published,
|
||||
// we'd retry it. The assumption here is that when an error is
|
||||
// returned from `PublishTransaction`, it means the tx has
|
||||
|
||||
Reference in new issue
Block a user