MCPcopy Create free account
hub / github.com/DOSNetwork/core / handleGroupFormation

Method handleGroupFormation

dosnode/dos_chain_handler.go:382–455  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

380}
381
382func (d *DosNode) handleGroupFormation() {
383 groupSize, err := d.chain.GroupSize()
384 if err != nil {
385 d.logger.Error(err)
386 return
387 }
388 pendingNodeSize, err := d.chain.NumPendingNodes()
389 if err != nil {
390 d.logger.Error(err)
391 return
392 }
393 expiredGroupSize, err := d.chain.GetExpiredWorkingGroupSize()
394 if err != nil {
395 d.logger.Error(err)
396 return
397 }
398 if pendingNodeSize < groupSize && expiredGroupSize > 0 {
399 d.chain.SignalGroupFormation()
400 return
401 }
402
403 workingGroup, err := d.chain.GetWorkingGroupSize()
404 if err != nil {
405 d.logger.Error(err)
406 return
407 }
408 bootstrapThreshold, err := d.chain.BootstrapStartThreshold()
409 if err != nil {
410 d.logger.Error(err)
411 return
412 }
413 if workingGroup == 0 && pendingNodeSize < bootstrapThreshold && expiredGroupSize > 0 {
414 d.chain.SignalGroupFormation()
415 return
416 }
417
418 if pendingNodeSize < groupSize {
419 d.logger.Debug(fmt.Sprintf("[DOS] Not enough pendingNodes (%v) vs groupSize (%v), skipping group formation ...", pendingNodeSize, groupSize))
420 return
421 }
422
423 groupToPick, err := d.chain.GroupToPick()
424 if err != nil {
425 d.logger.Error(err)
426 return
427 }
428 if workingGroup > 0 {
429 if expiredGroupSize >= groupToPick {
430 lastGrpFormReqId, err := d.chain.LastGroupFormationRequestId()
431 if err != nil {
432 d.logger.Error(err)
433 return
434 }
435 if lastGrpFormReqId != 0 {
436 d.logger.Debug("[DOS] Already in Group Formation Stage, skipping ...")
437 return
438 }
439 d.logger.Debug("[DOS] Signaling new group formation ...")

Callers 1

onchainLoopMethod · 0.95

Calls 11

GroupSizeMethod · 0.65
ErrorMethod · 0.65
NumPendingNodesMethod · 0.65
SignalGroupFormationMethod · 0.65
GetWorkingGroupSizeMethod · 0.65
DebugMethod · 0.65
GroupToPickMethod · 0.65
BootstrapRoundMethod · 0.65

Tested by

no test coverage detected