Skip to content

Commit 4f5f4ee

Browse files
committed
fixes after review
1 parent 6785359 commit 4f5f4ee

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

epochStart/bootstrap/process.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -829,26 +829,28 @@ func getLastReferencedMetaHash(
829829
return nil, epochStart.ErrWrongTypeAssertion
830830
}
831831

832+
var lastReferencedMetaHash []byte
833+
832834
currentHdr := lastExecutedShardHeader
833-
for {
835+
for currentHdr.GetNonce() > 0 {
834836
numIncludedMetaBlocks := len(currentHdr.GetMetaBlockHashes())
835837

836-
// if there are no included meta blocks, go to prev header
837-
if numIncludedMetaBlocks == 0 {
838-
header, err := fetchPrevHeader(syncedHeaders, currentHdr)
839-
if err != nil {
840-
return nil, err
841-
}
842-
843-
currentHdr = header
844-
continue
838+
// if there are notarized meta headers, return last included meta header
839+
if numIncludedMetaBlocks > 0 {
840+
lastReferencedMetaHash = currentHdr.GetMetaBlockHashes()[numIncludedMetaBlocks-1]
841+
break
845842
}
846843

847-
// if there are notarized meta headers, return last included meta header
848-
metaHash := currentHdr.GetMetaBlockHashes()[numIncludedMetaBlocks-1]
844+
// if there are no included meta blocks, go to prev header
845+
header, err := fetchPrevHeader(syncedHeaders, currentHdr)
846+
if err != nil {
847+
return nil, err
848+
}
849849

850-
return metaHash, nil
850+
currentHdr = header
851851
}
852+
853+
return lastReferencedMetaHash, nil
852854
}
853855

854856
func (e *epochStartBootstrap) syncPrevShardHeaderHandler(

0 commit comments

Comments
 (0)