MCPcopy Create free account
hub / github.com/DNAProject/DNA / BlockSignaturesReceived

Method BlockSignaturesReceived

consensus/dbft/dbft_service.go:544–588  ·  view source on GitHub ↗
(payload *p2pmsg.ConsensusPayload, message *BlockSignatures)

Source from the content-addressed store, hash-verified

542}
543
544func (ds *DbftService) BlockSignaturesReceived(payload *p2pmsg.ConsensusPayload, message *BlockSignatures) {
545 log.Info(fmt.Sprintf("BlockSignatures Received: height=%d View=%d index=%d", payload.Height, message.ViewNumber(), payload.BookkeeperIndex))
546
547 if ds.context.State.HasFlag(BlockGenerated) {
548 return
549 }
550
551 //if the signature already exist, needn't handle again
552 if ds.context.Signatures[payload.BookkeeperIndex] != nil {
553 return
554 }
555
556 header := ds.context.MakeHeader()
557 if header == nil {
558 return
559 }
560
561 blockHash := header.Hash()
562
563 for i := 0; i < len(message.Signatures); i++ {
564 sigdata := message.Signatures[i]
565
566 if ds.context.Signatures[sigdata.Index] != nil {
567 continue
568 }
569
570 err := signature.Verify(ds.context.Bookkeepers[sigdata.Index], blockHash[:], sigdata.Signature)
571 if err != nil {
572 continue
573 }
574
575 ds.context.Signatures[sigdata.Index] = sigdata.Signature
576 if ds.context.GetSignaturesCount() >= ds.context.M() {
577 log.Info("BlockSignatures got enough signatures")
578 break
579 }
580 }
581
582 err := ds.CheckSignatures()
583 if err != nil {
584 log.Error("CheckSignatures failed")
585 return
586 }
587 log.Info("BlockSignatures finished")
588}
589
590func (ds *DbftService) RefreshPolicy() {
591}

Callers 1

NewConsensusPayloadMethod · 0.95

Calls 10

CheckSignaturesMethod · 0.95
InfoFunction · 0.92
VerifyFunction · 0.92
ErrorFunction · 0.92
HasFlagMethod · 0.80
MakeHeaderMethod · 0.80
GetSignaturesCountMethod · 0.80
MMethod · 0.80
ViewNumberMethod · 0.65
HashMethod · 0.65

Tested by

no test coverage detected