Skip to content

Commit

Permalink
NOISSUE: add magic number to skip a couple of pulses before start
Browse files Browse the repository at this point in the history
  • Loading branch information
krestkrest committed Jan 21, 2019
1 parent 5be60a1 commit db796eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
10 changes: 4 additions & 6 deletions configuration/servicenetwork.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@

package configuration

// Service is configuration struct for servicenetwork.Service.
type Service struct {
}

// ServiceNetwork is configuration for ServiceNetwork.
type ServiceNetwork struct {
Service Service
Skip int // magic number that indicates what delta after last ignored pulse we should wait
}

// NewServiceNetwork creates a new ServiceNetwork configuration.
func NewServiceNetwork() ServiceNetwork {
return ServiceNetwork{}
return ServiceNetwork{
Skip: 10,
}
}
5 changes: 3 additions & 2 deletions network/servicenetwork/servicenetwork.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ type ServiceNetwork struct {

// fakePulsar *fakepulsar.FakePulsar
isGenesis bool
skip int
}

// NewServiceNetwork returns a new ServiceNetwork.
func NewServiceNetwork(conf configuration.Configuration, scheme core.PlatformCryptographyScheme, isGenesis bool) (*ServiceNetwork, error) {
serviceNetwork := &ServiceNetwork{cfg: conf, CryptographyScheme: scheme, isGenesis: isGenesis}
serviceNetwork := &ServiceNetwork{cfg: conf, CryptographyScheme: scheme, isGenesis: isGenesis, skip: conf.Service.Skip}
return serviceNetwork, nil
}

Expand Down Expand Up @@ -215,7 +216,7 @@ func (n *ServiceNetwork) HandlePulse(ctx context.Context, pulse core.Pulse) {
n.controller.SetLastIgnoredPulse(pulse.NextPulseNumber)
return
}
if pulse.PulseNumber <= n.controller.GetLastIgnoredPulse() {
if pulse.PulseNumber <= n.controller.GetLastIgnoredPulse()+core.PulseNumber(n.skip) {
log.Infof("Ignore pulse %d: network is not yet initialized", pulse.PulseNumber)
return
}
Expand Down

0 comments on commit db796eb

Please sign in to comment.