github.com/koko1123/flow-go-1@v0.29.6/module/epochs.go (about) 1 package module 2 3 import ( 4 "context" 5 6 "github.com/koko1123/flow-go-1/consensus/hotstuff/model" 7 "github.com/koko1123/flow-go-1/state/protocol" 8 ) 9 10 // ClusterRootQCVoter is responsible for submitting a vote to the cluster QC 11 // contract to coordinate generation of a valid root quorum certificate for the 12 // next epoch. 13 type ClusterRootQCVoter interface { 14 15 // Vote handles the full procedure of generating a vote, submitting it to the 16 // epoch smart contract, and verifying submission. Returns an error only if 17 // there is a critical error that would make it impossible for the vote to be 18 // submitted. Otherwise, exits when the vote has been successfully submitted. 19 // 20 // It is safe to run Vote multiple times within a single setup phase. 21 Vote(context.Context, protocol.Epoch) error 22 } 23 24 // QCContractClient enables interacting with the cluster QC aggregator smart 25 // contract. This contract is deployed to the service account as part of a 26 // collection of smart contracts that facilitate and manage epoch transitions. 27 type QCContractClient interface { 28 29 // SubmitVote submits the given vote to the cluster QC aggregator smart 30 // contract. This function returns only once the transaction has been 31 // processed by the network. An error is returned if the transaction has 32 // failed and should be re-submitted. 33 SubmitVote(ctx context.Context, vote *model.Vote) error 34 35 // Voted returns true if we have successfully submitted a vote to the 36 // cluster QC aggregator smart contract for the current epoch. 37 Voted(ctx context.Context) (bool, error) 38 } 39 40 // EpochLookup provides a method to find epochs by view. 41 type EpochLookup interface { 42 43 // EpochForView returns the counter of the epoch that the view belongs to. 44 EpochForView(view uint64) (epochCounter uint64, err error) 45 46 // EpochForViewWithFallback returns the counter of the epoch that the view belongs to. 47 EpochForViewWithFallback(view uint64) (epochCounter uint64, err error) 48 }