mirror of
https://source.quilibrium.com/quilibrium/ceremonyclient.git
synced 2024-12-23 23:25:17 +00:00
further refinements/tuning
This commit is contained in:
parent
09b04402df
commit
6058cbc4c6
@ -92,16 +92,17 @@ func (e *MasterClockConsensusEngine) handleSelfTestReport(
|
||||
info.DifficultyMetric = report.DifficultyMetric
|
||||
info.MasterHeadFrame = report.MasterHeadFrame
|
||||
|
||||
if info.Bandwidth <= 1048576 {
|
||||
if info.Bandwidth == 0 {
|
||||
go func() {
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), 5*time.Minute)
|
||||
defer cancel()
|
||||
ch := e.pubSub.GetMultiaddrOfPeerStream(ctx, peerID)
|
||||
select {
|
||||
case <-ch:
|
||||
go func() {
|
||||
e.bandwidthTestCh <- peerID
|
||||
}()
|
||||
select {
|
||||
case e.bandwidthTestCh <- peerID:
|
||||
default:
|
||||
}
|
||||
case <-ctx.Done():
|
||||
}
|
||||
}()
|
||||
@ -116,15 +117,16 @@ func (e *MasterClockConsensusEngine) handleSelfTestReport(
|
||||
for i := 0; i < len(proofs); i++ {
|
||||
proofs[i] = proof[i*516 : (i+1)*516]
|
||||
}
|
||||
go func() {
|
||||
e.verifyTestCh <- verifyChallenge{
|
||||
peerID: peerID,
|
||||
challenge: challenge,
|
||||
cores: report.Cores,
|
||||
increment: report.Increment,
|
||||
proof: proof,
|
||||
}
|
||||
}()
|
||||
select {
|
||||
case e.verifyTestCh <- verifyChallenge{
|
||||
peerID: peerID,
|
||||
challenge: challenge,
|
||||
cores: report.Cores,
|
||||
increment: report.Increment,
|
||||
proof: proof,
|
||||
}:
|
||||
default:
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ func NewMasterClockConsensusEngine(
|
||||
report: report,
|
||||
frameValidationCh: make(chan *protobufs.ClockFrame),
|
||||
bandwidthTestCh: make(chan []byte),
|
||||
verifyTestCh: make(chan verifyChallenge, 120000),
|
||||
verifyTestCh: make(chan verifyChallenge, 4),
|
||||
engineConfig: engineConfig,
|
||||
}
|
||||
|
||||
@ -192,29 +192,14 @@ func (e *MasterClockConsensusEngine) Start() <-chan error {
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case newFrame := <-e.frameValidationCh:
|
||||
head, err := e.masterTimeReel.Head()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if head.FrameNumber > newFrame.FrameNumber ||
|
||||
newFrame.FrameNumber-head.FrameNumber > 128 {
|
||||
e.logger.Debug(
|
||||
"frame out of range, ignoring",
|
||||
zap.Uint64("number", newFrame.FrameNumber),
|
||||
)
|
||||
continue
|
||||
}
|
||||
|
||||
if err := e.frameProver.VerifyMasterClockFrame(newFrame); err != nil {
|
||||
e.logger.Error("could not verify clock frame", zap.Error(err))
|
||||
continue
|
||||
}
|
||||
|
||||
e.masterTimeReel.Insert(newFrame, false)
|
||||
case peerId := <-e.bandwidthTestCh:
|
||||
e.performBandwidthTest(peerId)
|
||||
}
|
||||
}
|
||||
}()
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case verifyTest := <-e.verifyTestCh:
|
||||
e.performVerifyTest(verifyTest)
|
||||
}
|
||||
@ -398,12 +383,11 @@ func (e *MasterClockConsensusEngine) Start() <-chan error {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
e.logger.Info(
|
||||
"broadcasting self-test info",
|
||||
zap.Uint64("current_frame", e.report.MasterHeadFrame),
|
||||
)
|
||||
|
||||
if increment%30 == 0 {
|
||||
e.logger.Info(
|
||||
"broadcasting self-test info",
|
||||
zap.Uint64("current_frame", e.report.MasterHeadFrame),
|
||||
)
|
||||
if err := e.publishMessage(e.filter, e.report); err != nil {
|
||||
e.logger.Debug("error publishing message", zap.Error(err))
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ func main() {
|
||||
fmt.Println("Signature check disabled, skipping...")
|
||||
}
|
||||
|
||||
if *memprofile != "" {
|
||||
if *memprofile != "" && *core == 0 {
|
||||
go func() {
|
||||
for {
|
||||
time.Sleep(5 * time.Minute)
|
||||
@ -241,7 +241,7 @@ func main() {
|
||||
}()
|
||||
}
|
||||
|
||||
if *cpuprofile != "" {
|
||||
if *cpuprofile != "" && *core == 0 {
|
||||
f, err := os.Create(*cpuprofile)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
Loading…
Reference in New Issue
Block a user