Skip to content

Commit

Permalink
update throttle
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangchiqing committed Mar 4, 2024
1 parent 44f6929 commit b118353
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions engine/execution/ingestion/throttle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit b118353

Please sign in to comment.