multi: start consumers with a starting blockbeat

This is needed so the consumers have an initial state about the current
block.
This commit is contained in:
yyforyongyu committed 2024-12-20 17:54:02 +08:00
1 parent 802353036e
commit 545cea0546
5 files changed
+60 -10

No files matched your search

+6 -3
View File
@@ -570,13 +570,16 @@ func (c *ChainArbitrator) ResolveContract(chanPoint wire.OutPoint) error {
}
// Start launches all goroutines that the ChainArbitrator needs to operate.
func (c *ChainArbitrator) Start() error {
func (c *ChainArbitrator) Start(beat chainio.Blockbeat) error {
if !atomic.CompareAndSwapInt32(&c.started, 0, 1) {
return nil
}
log.Infof("ChainArbitrator starting with config: budget=[%v]",
&c.cfg.Budget)
// Set the current beat.
c.beat = beat
log.Infof("ChainArbitrator starting at height %d with budget=[%v]",
&c.cfg.Budget, c.beat.Height())
// First, we'll fetch all the channels that are still open, in order to
// collect them within our set of active contracts.
+4 -2
View File
@@ -90,7 +90,8 @@ func TestChainArbitratorRepublishCloses(t *testing.T) {
chainArbCfg, db,
)
if err := chainArb.Start(); err != nil {
beat := newBeatFromHeight(0)
if err := chainArb.Start(beat); err != nil {
t.Fatal(err)
}
t.Cleanup(func() {
@@ -173,7 +174,8 @@ func TestResolveContract(t *testing.T) {
chainArb := NewChainArbitrator(
chainArbCfg, db,
)
if err := chainArb.Start(); err != nil {
beat := newBeatFromHeight(0)
if err := chainArb.Start(beat); err != nil {
t.Fatal(err)
}
t.Cleanup(func() {