github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/consensus/hotstuff/pacemaker/proposal_timing.go (about)

     1  package pacemaker
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/onflow/flow-go/consensus/hotstuff"
     7  	"github.com/onflow/flow-go/model/flow"
     8  )
     9  
    10  // StaticProposalDurationProvider is a hotstuff.ProposalDurationProvider which provides a static ProposalDuration.
    11  // The constant dur represents the time to produce and broadcast the proposal (ProposalDuration),
    12  // NOT the time for the entire view (ViewDuration).
    13  type StaticProposalDurationProvider struct {
    14  	dur time.Duration
    15  }
    16  
    17  var _ hotstuff.ProposalDurationProvider = (*StaticProposalDurationProvider)(nil)
    18  
    19  func NewStaticProposalDurationProvider(dur time.Duration) StaticProposalDurationProvider {
    20  	return StaticProposalDurationProvider{dur: dur}
    21  }
    22  
    23  func (p StaticProposalDurationProvider) TargetPublicationTime(_ uint64, timeViewEntered time.Time, _ flow.Identifier) time.Time {
    24  	return timeViewEntered.Add(p.dur)
    25  }
    26  
    27  func NoProposalDelay() StaticProposalDurationProvider {
    28  	return NewStaticProposalDurationProvider(0)
    29  }