github.com/unicornultrafoundation/go-u2u@v1.0.0-rc1.0.20240205080301-e74a83d3fadc/eventcheck/bvallcheck/all_check.go (about) 1 package bvallcheck 2 3 import ( 4 "github.com/unicornultrafoundation/go-u2u/native" 5 ) 6 7 type Checker struct { 8 HeavyCheck HeavyCheck 9 LightCheck LightCheck 10 } 11 12 type LightCheck func(bvs native.LlrSignedBlockVotes) error 13 14 type HeavyCheck interface { 15 Enqueue(bvs native.LlrSignedBlockVotes, checked func(error)) error 16 } 17 18 type Callback struct { 19 HeavyCheck HeavyCheck 20 LightCheck LightCheck 21 } 22 23 // Enqueue tries to fill gaps the fetcher's future import queue. 24 func (c *Checker) Enqueue(bvs native.LlrSignedBlockVotes, checked func(error)) { 25 // Run light checks right away 26 err := c.LightCheck(bvs) 27 if err != nil { 28 checked(err) 29 return 30 } 31 32 // Run heavy check in parallel 33 _ = c.HeavyCheck.Enqueue(bvs, checked) 34 }