|
5 | 5 |
|
6 | 6 | "go.sia.tech/core/types" |
7 | 7 | "go.sia.tech/coreutils/chain" |
| 8 | + "go.uber.org/zap" |
8 | 9 | ) |
9 | 10 |
|
10 | 11 | type ( |
@@ -589,21 +590,25 @@ func updateMetrics(tx UpdateTx, s UpdateState, metrics Metrics) (Metrics, error) |
589 | 590 | } |
590 | 591 |
|
591 | 592 | // UpdateChainState applies the reverts and updates. |
592 | | -func UpdateChainState(tx UpdateTx, crus []chain.RevertUpdate, caus []chain.ApplyUpdate) error { |
| 593 | +func UpdateChainState(tx UpdateTx, crus []chain.RevertUpdate, caus []chain.ApplyUpdate, log *zap.Logger) error { |
593 | 594 | for _, cru := range crus { |
594 | 595 | revertedIndex := types.ChainIndex{ |
595 | 596 | ID: cru.Block.ID(), |
596 | 597 | Height: cru.State.Index.Height + 1, |
597 | 598 | } |
| 599 | + log.Debug("reverting chain update", zap.Stringer("index", revertedIndex)) |
598 | 600 | if err := revertChainUpdate(tx, cru, revertedIndex); err != nil { |
599 | 601 | return fmt.Errorf("failed to revert chain update %q: %w", revertedIndex, err) |
600 | 602 | } |
| 603 | + log.Debug("reverted chain update", zap.Stringer("index", revertedIndex)) |
601 | 604 | } |
602 | 605 |
|
603 | 606 | for _, cau := range caus { |
| 607 | + log.Debug("applying chain update", zap.Stringer("index", cau.State.Index)) |
604 | 608 | if err := applyChainUpdate(tx, cau); err != nil { |
605 | 609 | return fmt.Errorf("failed to apply chain update %q: %w", cau.State.Index, err) |
606 | 610 | } |
| 611 | + log.Debug("applied chain update", zap.Stringer("index", cau.State.Index)) |
607 | 612 | } |
608 | 613 | return nil |
609 | 614 | } |
0 commit comments