github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/x/infura/cache_queue.go (about) 1 package infura 2 3 type CacheQueue struct { 4 queue chan StreamContext 5 } 6 7 type StreamContext struct { 8 blockHeight int64 9 task *Task 10 stream *Stream 11 } 12 13 func newCacheQueue(queueNum int) *CacheQueue { 14 cacheQueue := &CacheQueue{ 15 queue: make(chan StreamContext, queueNum), 16 } 17 return cacheQueue 18 } 19 20 func (cq *CacheQueue) Start() { 21 for { 22 streamContext := <-cq.queue 23 execute(streamContext) 24 } 25 } 26 27 func (cq *CacheQueue) Enqueue(sc StreamContext) { 28 cq.queue <- sc 29 }