github.com/koko1123/flow-go-1@v0.29.6/consensus/hotstuff/integration/assertion_test.go (about)

     1  package integration
     2  
     3  import "github.com/koko1123/flow-go-1/model/flow"
     4  
     5  func FinalizedBlocks(in *Instance) []*flow.Header {
     6  	finalized := make([]*flow.Header, 0)
     7  
     8  	lastFinalID := in.forks.FinalizedBlock().BlockID
     9  	in.updatingBlocks.RLock()
    10  	finalizedBlock, found := in.headers[lastFinalID]
    11  	defer in.updatingBlocks.RUnlock()
    12  	if !found {
    13  		return finalized
    14  	}
    15  
    16  	for {
    17  		finalized = append(finalized, finalizedBlock)
    18  		finalizedBlock, found = in.headers[finalizedBlock.ParentID]
    19  		if !found {
    20  			break
    21  		}
    22  	}
    23  	return finalized
    24  }
    25  
    26  func FinalizedViews(in *Instance) []uint64 {
    27  	finalizedBlocks := FinalizedBlocks(in)
    28  	views := make([]uint64, 0, len(finalizedBlocks))
    29  	for _, b := range finalizedBlocks {
    30  		views = append(views, b.View)
    31  	}
    32  	return views
    33  }