From 8436f8aeb0152920bb48cf433ec2037c42a5b4e4 Mon Sep 17 00:00:00 2001 From: "Leo Zhang (zhangchiqing)" Date: Thu, 21 Dec 2023 08:37:28 -0800 Subject: [PATCH] optimize finalized reader to use block id index --- module/finalizedreader/finalizedreader.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/finalizedreader/finalizedreader.go b/module/finalizedreader/finalizedreader.go index 01b6e4ec5ce..19012407d30 100644 --- a/module/finalizedreader/finalizedreader.go +++ b/module/finalizedreader/finalizedreader.go @@ -32,12 +32,12 @@ func (r *FinalizedReader) FinalizedBlockIDAtHeight(height uint64) (flow.Identifi return flow.ZeroID, fmt.Errorf("height not finalized (%v): %w", height, storage.ErrNotFound) } - header, err := r.headers.ByHeight(height) + finalizedID, err := r.headers.BlockIDByHeight(height) if err != nil { return flow.ZeroID, err } - return header.ID(), nil + return finalizedID, nil } // BlockFinalized implements the protocol.Consumer interface, which allows FinalizedReader