beacon: add constructor

This commit is contained in:
Joost Jager 2022-04-13 10:19:25 +02:00
parent 57e08dfa54
commit 7265a5e42b
No known key found for this signature in database
GPG key ID: A61B9D4C393C59C7
2 changed files with 8 additions and 4 deletions

View file

@ -595,10 +595,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
quit: make(chan struct{}),
}
s.witnessBeacon = &preimageBeacon{
wCache: dbs.ChanStateDB.NewWitnessCache(),
subscribers: make(map[uint64]*preimageSubscriber),
}
s.witnessBeacon = newPreimageBeacon(dbs.ChanStateDB.NewWitnessCache())
currentHash, currentHeight, err := s.cc.ChainIO.GetBestBlock()
if err != nil {

View file

@ -28,6 +28,13 @@ type preimageBeacon struct {
subscribers map[uint64]*preimageSubscriber
}
func newPreimageBeacon(wCache *channeldb.WitnessCache) *preimageBeacon {
return &preimageBeacon{
wCache: wCache,
subscribers: make(map[uint64]*preimageSubscriber),
}
}
// SubscribeUpdates returns a channel that will be sent upon *each* time a new
// preimage is discovered.
func (p *preimageBeacon) SubscribeUpdates() *contractcourt.WitnessSubscription {