forked from maticnetwork/bor
/
bor_filter_system.go
31 lines (27 loc) · 940 Bytes
/
bor_filter_system.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package filters
import (
"time"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/rpc"
)
func (es *EventSystem) handleStateSyncEvent(filters filterIndex, ev core.StateSyncEvent) {
for _, f := range filters[StateSyncSubscription] {
f.stateSyncData <- ev.Data
}
}
// SubscribeNewDeposits creates a subscription that writes details about the new state sync events (from mainchain to Bor)
func (es *EventSystem) SubscribeNewDeposits(data chan *types.StateSyncData) *Subscription {
sub := &subscription{
id: rpc.NewID(),
typ: StateSyncSubscription,
created: time.Now(),
logs: make(chan []*types.Log),
txs: make(chan []*types.Transaction),
headers: make(chan *types.Header),
stateSyncData: data,
installed: make(chan struct{}),
err: make(chan error),
}
return es.subscribe(sub)
}