Skip to content

Commit

Permalink
Fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
fasmat committed Aug 13, 2024
1 parent 7ec8029 commit 7f0eae0
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 67 deletions.
30 changes: 15 additions & 15 deletions hare3/hare.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ type Opt func(*Hare)

func WithWallclock(clock clockwork.Clock) Opt {
return func(hr *Hare) {
hr.wallclock = clock
hr.wallClock = clock
}
}

Expand Down Expand Up @@ -163,15 +163,15 @@ func WithResultsChan(c chan hare4.ConsensusOutput) Opt {
}
}

type nodeclock interface {
type nodeClock interface {
AwaitLayer(types.LayerID) <-chan struct{}
CurrentLayer() types.LayerID
LayerToTime(types.LayerID) time.Time
}

func New(
nodeclock nodeclock,
pubsub pubsub.PublishSubsciber,
nodeClock nodeClock,
pubsub pubsub.PublishSubscriber,
db *sql.Database,
atxsdata *atxsdata.Data,
proposals *store.Store,
Expand All @@ -192,9 +192,9 @@ func New(

config: DefaultConfig(),
log: zap.NewNop(),
wallclock: clockwork.NewRealClock(),
wallClock: clockwork.NewRealClock(),

nodeclock: nodeclock,
nodeClock: nodeClock,
pubsub: pubsub,
db: db,
atxsdata: atxsdata,
Expand Down Expand Up @@ -229,11 +229,11 @@ type Hare struct {
// options
config Config
log *zap.Logger
wallclock clockwork.Clock
wallClock clockwork.Clock

// dependencies
nodeclock nodeclock
pubsub pubsub.PublishSubsciber
nodeClock nodeClock
pubsub pubsub.PublishSubscriber
db *sql.Database
atxsdata *atxsdata.Data
proposals *store.Store
Expand Down Expand Up @@ -261,7 +261,7 @@ func (h *Hare) Coins() <-chan hare4.WeakCoinOutput {

func (h *Hare) Start() {
h.pubsub.Register(h.config.ProtocolName, h.Handler, pubsub.WithValidatorInline(true))
current := h.nodeclock.CurrentLayer() + 1
current := h.nodeClock.CurrentLayer() + 1
enabled := max(current, h.config.EnableLayer, types.GetEffectiveGenesis()+1)
disabled := types.LayerID(math.MaxUint32)
if h.config.DisableLayer > 0 {
Expand All @@ -275,7 +275,7 @@ func (h *Hare) Start() {
h.eg.Go(func() error {
for next := enabled; next < disabled; next++ {
select {
case <-h.nodeclock.AwaitLayer(next):
case <-h.nodeClock.AwaitLayer(next):
h.log.Debug("notified", zap.Uint32("lid", next.Uint32()))
h.onLayer(next)
case <-h.ctx.Done():
Expand Down Expand Up @@ -349,7 +349,7 @@ func (h *Hare) Handler(ctx context.Context, peer p2p.Peer, buf []byte) error {
droppedMessages.Inc()
return errors.New("dropped by graded gossip")
}
expected := h.nodeclock.LayerToTime(msg.Layer).Add(h.config.roundStart(msg.IterRound))
expected := h.nodeClock.LayerToTime(msg.Layer).Add(h.config.roundStart(msg.IterRound))
metrics.ReportMessageLatency(h.config.ProtocolName, msg.Round.String(), time.Since(expected))
return nil
}
Expand Down Expand Up @@ -426,12 +426,12 @@ func (h *Hare) run(session *session) error {
h.tracer.OnActive(session.vrfs)
activeLatency.Observe(time.Since(start).Seconds())

walltime := h.nodeclock.LayerToTime(session.lid).Add(h.config.PreroundDelay)
walltime := h.nodeClock.LayerToTime(session.lid).Add(h.config.PreroundDelay)
if active {
h.log.Debug("active in preround. waiting for preround delay", zap.Uint32("lid", session.lid.Uint32()))
// initial set is not needed if node is not active in preround
select {
case <-h.wallclock.After(walltime.Sub(h.wallclock.Now())):
case <-h.wallClock.After(walltime.Sub(h.wallClock.Now())):
case <-h.ctx.Done():
return h.ctx.Err()
}
Expand Down Expand Up @@ -459,7 +459,7 @@ func (h *Hare) run(session *session) error {
activeLatency.Observe(time.Since(start).Seconds())

select {
case <-h.wallclock.After(walltime.Sub(h.wallclock.Now())):
case <-h.wallClock.After(walltime.Sub(h.wallClock.Now())):
h.log.Debug("execute round",
zap.Uint32("lid", session.lid.Uint32()),
zap.Uint8("iter", session.proto.Iter), zap.Stringer("round", session.proto.Round),
Expand Down
4 changes: 2 additions & 2 deletions hare3/hare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ type node struct {
proposals *store.Store

ctrl *gomock.Controller
mpublisher *pmocks.MockPublishSubsciber
mpublisher *pmocks.MockPublishSubscriber
msyncer *smocks.MockSyncStateProvider
patrol *layerpatrol.LayerPatrol
tracer *testTracer
Expand Down Expand Up @@ -203,7 +203,7 @@ func (n *node) withOracle() *node {
}

func (n *node) withPublisher() *node {
n.mpublisher = pmocks.NewMockPublishSubsciber(n.ctrl)
n.mpublisher = pmocks.NewMockPublishSubscriber(n.ctrl)
n.mpublisher.EXPECT().Register(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes()
return n
}
Expand Down
34 changes: 17 additions & 17 deletions hare4/hare.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func WithServer(s streamRequester) Opt {

func WithWallclock(clock clockwork.Clock) Opt {
return func(hr *Hare) {
hr.wallclock = clock
hr.wallClock = clock
}
}

Expand Down Expand Up @@ -185,19 +185,19 @@ func WithResultsChan(c chan ConsensusOutput) Opt {
}
}

type nodeclock interface {
type nodeClock interface {
AwaitLayer(types.LayerID) <-chan struct{}
CurrentLayer() types.LayerID
LayerToTime(types.LayerID) time.Time
}

func New(
nodeclock nodeclock,
pubsub pubsub.PublishSubsciber,
nodeClock nodeClock,
pubsub pubsub.PublishSubscriber,
db *sql.Database,
atxsdata *atxsdata.Data,
proposals *store.Store,
verif verifier,
verifier verifier,
oracle oracle,
sync system.SyncStateProvider,
patrol *layerpatrol.LayerPatrol,
Expand All @@ -216,14 +216,14 @@ func New(

config: DefaultConfig(),
log: zap.NewNop(),
wallclock: clockwork.NewRealClock(),
wallClock: clockwork.NewRealClock(),

nodeclock: nodeclock,
nodeClock: nodeClock,
pubsub: pubsub,
db: db,
atxsdata: atxsdata,
proposals: proposals,
verifier: verif,
verifier: verifier,
oracle: &legacyOracle{
log: zap.NewNop(),
oracle: oracle,
Expand Down Expand Up @@ -258,11 +258,11 @@ type Hare struct {
// options
config Config
log *zap.Logger
wallclock clockwork.Clock
wallClock clockwork.Clock

// dependencies
nodeclock nodeclock
pubsub pubsub.PublishSubsciber
nodeClock nodeClock
pubsub pubsub.PublishSubscriber
db *sql.Database
atxsdata *atxsdata.Data
proposals *store.Store
Expand Down Expand Up @@ -291,7 +291,7 @@ func (h *Hare) Coins() <-chan WeakCoinOutput {

func (h *Hare) Start() {
h.pubsub.Register(h.config.ProtocolName, h.Handler, pubsub.WithValidatorInline(true))
current := h.nodeclock.CurrentLayer() + 1
current := h.nodeClock.CurrentLayer() + 1
enabled := max(current, h.config.EnableLayer, types.GetEffectiveGenesis()+1)
disabled := types.LayerID(math.MaxUint32)
if h.config.DisableLayer > 0 {
Expand All @@ -305,7 +305,7 @@ func (h *Hare) Start() {
h.eg.Go(func() error {
for next := enabled; next < disabled; next++ {
select {
case <-h.nodeclock.AwaitLayer(next):
case <-h.nodeClock.AwaitLayer(next):
h.log.Debug("notified", zap.Uint32("layer", next.Uint32()))
h.onLayer(next)
h.cleanMessageCache(next - 1)
Expand Down Expand Up @@ -560,7 +560,7 @@ func (h *Hare) Handler(ctx context.Context, peer p2p.Peer, buf []byte) error {
droppedMessages.Inc()
return errors.New("dropped by graded gossip")
}
expected := h.nodeclock.LayerToTime(msg.Layer).Add(h.config.roundStart(msg.IterRound))
expected := h.nodeClock.LayerToTime(msg.Layer).Add(h.config.roundStart(msg.IterRound))
metrics.ReportMessageLatency(h.config.ProtocolName, msg.Round.String(), time.Since(expected))
return nil
}
Expand Down Expand Up @@ -637,12 +637,12 @@ func (h *Hare) run(session *session) error {
h.tracer.OnActive(session.vrfs)
activeLatency.Observe(time.Since(start).Seconds())

walltime := h.nodeclock.LayerToTime(session.lid).Add(h.config.PreroundDelay)
walltime := h.nodeClock.LayerToTime(session.lid).Add(h.config.PreroundDelay)
if active {
h.log.Debug("active in preround. waiting for preround delay", zap.Uint32("lid", session.lid.Uint32()))
// initial set is not needed if node is not active in preround
select {
case <-h.wallclock.After(walltime.Sub(h.wallclock.Now())):
case <-h.wallClock.After(walltime.Sub(h.wallClock.Now())):
case <-h.ctx.Done():
return h.ctx.Err()
}
Expand Down Expand Up @@ -670,7 +670,7 @@ func (h *Hare) run(session *session) error {
activeLatency.Observe(time.Since(start).Seconds())

select {
case <-h.wallclock.After(walltime.Sub(h.wallclock.Now())):
case <-h.wallClock.After(walltime.Sub(h.wallClock.Now())):
h.log.Debug("execute round",
zap.Uint32("lid", session.lid.Uint32()),
zap.Uint8("iter", session.proto.Iter), zap.Stringer("round", session.proto.Round),
Expand Down
4 changes: 2 additions & 2 deletions hare4/hare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ type node struct {
proposals *store.Store

ctrl *gomock.Controller
mpublisher *pmocks.MockPublishSubsciber
mpublisher *pmocks.MockPublishSubscriber
msyncer *smocks.MockSyncStateProvider
mverifier *hmock.Mockverifier
mockStreamRequester *hmock.MockstreamRequester
Expand Down Expand Up @@ -219,7 +219,7 @@ func (n *node) withOracle() *node {
}

func (n *node) withPublisher() *node {
n.mpublisher = pmocks.NewMockPublishSubsciber(n.ctrl)
n.mpublisher = pmocks.NewMockPublishSubscriber(n.ctrl)
n.mpublisher.EXPECT().Register(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes()
return n
}
Expand Down
58 changes: 29 additions & 29 deletions p2p/pubsub/mocks/publisher.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7f0eae0

Please sign in to comment.