feat(service): wire EventBus into BlockchainService
Some checks failed
Security Scan / security (push) Successful in 13s
Test / Test (push) Failing after 36s

BlockchainService now has an EventBus that emits:
- EventBlockNew on every synced block (with hash)
- EventAlias when a block contains an alias registration

Chain's BlockCallback → EventBus.Emit → subscribers.
Ready for core/stream SSEBroker integration.

Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
Claude 2026-04-02 04:44:24 +01:00
parent 8a4a9c0cb7
commit cd2f4ff092
No known key found for this signature in database
GPG key ID: AF404715446AEB41

View file

@ -36,6 +36,7 @@ type BlockchainService struct {
chain *chain.Chain
store *store.Store
daemon *daemon.Server
events *EventBus
cancel context.CancelFunc
}
@ -76,6 +77,15 @@ func (s *BlockchainService) start() core.Result {
}
s.store = st
s.chain = chain.New(st)
s.events = NewEventBus()
// Wire block events
s.chain.SetBlockCallback(func(height uint64, hash string, aliasName string) {
s.events.Emit(Event{Type: EventBlockNew, Height: height, Data: hash})
if aliasName != "" {
s.events.Emit(Event{Type: EventAlias, Height: height, Data: aliasName})
}
})
cfg, forks := resolveConfig(s.opts.Testnet, &s.opts.Seed)