(payload *p2pmsg.ConsensusPayload, message *BlockSignatures)
| 542 | } |
| 543 | |
| 544 | func (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 | |
| 590 | func (ds *DbftService) RefreshPolicy() { |
| 591 | } |
no test coverage detected