From b1183536fc1342483980c2c92c71d2e4bd77f44d Mon Sep 17 00:00:00 2001 From: "Leo Zhang (zhangchiqing)" Date: Fri, 2 Feb 2024 10:58:47 -0800 Subject: [PATCH] update throttle --- engine/execution/ingestion/throttle.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/engine/execution/ingestion/throttle.go b/engine/execution/ingestion/throttle.go index b98157dbda2..16ca08797e9 100644 --- a/engine/execution/ingestion/throttle.go +++ b/engine/execution/ingestion/throttle.go @@ -42,10 +42,6 @@ type BlockThrottle struct { headers storage.Headers } -type BlockHandler interface { - OnBlock(block *flow.Header) error -} - func NewBlockThrottle( log zerolog.Logger, state protocol.State, @@ -108,7 +104,7 @@ func (c *BlockThrottle) Init(processables chan<- flow.Identifier) error { return nil } -func (c *BlockThrottle) OnBlockExecuted(executed uint64, _ flow.Identifier) error { +func (c *BlockThrottle) OnBlockExecuted(_ flow.Identifier, executed uint64) error { c.mu.Lock() defer c.mu.Unlock() @@ -148,21 +144,22 @@ func (c *BlockThrottle) OnBlockExecuted(executed uint64, _ flow.Identifier) erro return nil } -func (c *BlockThrottle) BlockProcessable(block *flow.Header, qc *flow.QuorumCertificate) { +func (c *BlockThrottle) OnBlock(blockID flow.Identifier) error { c.mu.Lock() defer c.mu.Unlock() if !c.inited { - return + return fmt.Errorf("throttle not inited") } // ignore the block if has not caught up. if !c.caughtUp() { - return + return nil } // if has caught up, then process the block - c.processables <- qc.BlockID + c.processables <- blockID + return nil } func (c *BlockThrottle) OnBlockFinalized(lastFinalized *flow.Header) {