Skip to content

Commit d7790e4

Browse files
authored
Broadcast open short answers 2 minutes after the start of validation (#819)
1 parent 9b0e2fd commit d7790e4

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

core/ceremony/ceremony.go

+15-8
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,21 @@ func (vc *ValidationCeremony) restoreState() {
321321
if stopFlipKeysStopTime.Before(time.Now().UTC()) {
322322
vc.stopFlipKeysSync()
323323
}
324+
go vc.shortSessionAnswersBroadcastLoop()
325+
}
326+
327+
func (vc *ValidationCeremony) shortSessionAnswersBroadcastLoop() {
328+
for {
329+
time.Sleep(time.Second * 5)
330+
if vc.appState.State.ValidationPeriod() != state.NonePeriod {
331+
if !vc.shortAnswersSent && vc.appState.EvidenceMap.IsCompleted() {
332+
if vc.shouldInteractWithNetwork() {
333+
time.Sleep(time.Duration(rand.Intn(MaxShortAnswersBroadcastDelaySec)) * time.Second)
334+
vc.broadcastShortAnswersTx()
335+
}
336+
}
337+
}
338+
}
324339
}
325340

326341
func (vc *ValidationCeremony) startValidationShortSessionTimer() {
@@ -473,7 +488,6 @@ func (vc *ValidationCeremony) startShortSession(appState *appstate.AppState) {
473488
func (vc *ValidationCeremony) handleLongSessionPeriod(block *types.Block) {
474489
if block.Header.Flags().HasFlag(types.LongSessionStarted) {
475490
vc.logInfoWithInteraction("Long session started")
476-
go vc.delayedShortAnswersTxBroadcast()
477491
}
478492

479493
vc.processCeremonyTxs(block)
@@ -759,13 +773,6 @@ func (vc *ValidationCeremony) processCeremonyTxs(block *types.Block) {
759773
}
760774
}
761775

762-
func (vc *ValidationCeremony) delayedShortAnswersTxBroadcast() {
763-
if vc.shouldInteractWithNetwork() {
764-
time.Sleep(time.Duration(rand.Intn(MaxShortAnswersBroadcastDelaySec)) * time.Second)
765-
vc.broadcastShortAnswersTx()
766-
}
767-
}
768-
769776
func (vc *ValidationCeremony) broadcastShortAnswersTx() {
770777
if vc.shortAnswersSent || !vc.shouldInteractWithNetwork() || !vc.isParticipant() {
771778
return

0 commit comments

Comments
 (0)