beacon: add constructor

This commit is contained in:
Joost Jager committed 2022-04-13 11:31:29 +02:00
1 parent 57e08dfa54
commit 7265a5e42b
2 files changed
+8 -4

No files matched your search

+1 -4
View File
@@ -595,10 +595,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
quit: make(chan struct{}), quit: make(chan struct{}),
} }
s.witnessBeacon = &preimageBeacon{ s.witnessBeacon = newPreimageBeacon(dbs.ChanStateDB.NewWitnessCache())
wCache: dbs.ChanStateDB.NewWitnessCache(),
subscribers: make(map[uint64]*preimageSubscriber),
}
currentHash, currentHeight, err := s.cc.ChainIO.GetBestBlock() currentHash, currentHeight, err := s.cc.ChainIO.GetBestBlock()
if err != nil { if err != nil {
+7
View File
@@ -28,6 +28,13 @@ type preimageBeacon struct {
subscribers map[uint64]*preimageSubscriber 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 // SubscribeUpdates returns a channel that will be sent upon *each* time a new
// preimage is discovered. // preimage is discovered.
func (p *preimageBeacon) SubscribeUpdates() *contractcourt.WitnessSubscription { func (p *preimageBeacon) SubscribeUpdates() *contractcourt.WitnessSubscription {