mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-23 12:07:17 +00:00
393c9965ae
* fix `make grpc` on new checkouts * update proto files * add some stub * prototype with fake events * notifying about events * pass events * events are being sent * transfer headers to filters * create the “filters” struct * implement new heads * PoC of New Heads subscription * fix keep alive * fixups for the client * add “type” to the event * support header event type on client * better stage refactor * fixup for the eth backend * fixups * fix tests * fix tests * fix linters * address comments * remove unused log
36 lines
606 B
Go
36 lines
606 B
Go
package remotedbserver
|
|
|
|
import (
|
|
"github.com/ledgerwatch/turbo-geth/core/types"
|
|
)
|
|
|
|
type RpcEventType uint64
|
|
|
|
const (
|
|
EventTypeHeader = RpcEventType(iota)
|
|
)
|
|
|
|
type HeaderSubscription func(*types.Header) error
|
|
|
|
type Events struct {
|
|
headerSubscription HeaderSubscription
|
|
}
|
|
|
|
func NewEvents() *Events {
|
|
return &Events{}
|
|
}
|
|
|
|
func (e *Events) AddHeaderSubscription(s HeaderSubscription) {
|
|
e.headerSubscription = s
|
|
}
|
|
|
|
func (e *Events) OnNewHeader(newHeader *types.Header) {
|
|
if e.headerSubscription == nil {
|
|
return
|
|
}
|
|
err := e.headerSubscription(newHeader)
|
|
if err != nil {
|
|
e.headerSubscription = nil
|
|
}
|
|
}
|