github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/state/protocol/events/gadgets/identity_deltas.go (about) 1 package gadgets 2 3 import ( 4 "github.com/onflow/flow-go/model/flow" 5 "github.com/onflow/flow-go/state/protocol/events" 6 ) 7 8 // IdentityDeltas is a protocol events consumer that provides an interface to 9 // subscribe to callbacks any time an identity table change (or possible change) 10 // is finalized. 11 // 12 // TODO add slashing/ejection events here once implemented 13 type IdentityDeltas struct { 14 events.Noop 15 callback func() 16 } 17 18 // NewIdentityDeltas returns a new IdentityDeltas events gadget. 19 func NewIdentityDeltas(cb func()) *IdentityDeltas { 20 deltas := &IdentityDeltas{ 21 callback: cb, 22 } 23 return deltas 24 } 25 26 func (g *IdentityDeltas) EpochTransition(_ uint64, _ *flow.Header) { 27 g.callback() 28 } 29 30 func (g *IdentityDeltas) EpochSetupPhaseStarted(_ uint64, _ *flow.Header) { 31 g.callback() 32 } 33 34 func (g *IdentityDeltas) EpochCommittedPhaseStarted(_ uint64, _ *flow.Header) { 35 g.callback() 36 }