本文整理匯總了Golang中github.com/hyperledger/fabric/gossip/comm.ReceivedMessage.Respond方法的典型用法代碼示例。如果您正苦於以下問題:Golang ReceivedMessage.Respond方法的具體用法?Golang ReceivedMessage.Respond怎麽用?Golang ReceivedMessage.Respond使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/hyperledger/fabric/gossip/comm.ReceivedMessage
的用法示例。
在下文中一共展示了ReceivedMessage.Respond方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: handleStateRequest
func (s *GossipStateProviderImpl) handleStateRequest(msg comm.ReceivedMessage) {
request := msg.GetGossipMessage().GetStateRequest()
response := &proto.RemoteStateResponse{Payloads: make([]*proto.Payload, 0)}
for _, seqNum := range request.SeqNums {
s.logger.Debug("Reading block ", seqNum, " from the committer service")
blocks := s.committer.GetBlocks([]uint64{seqNum})
if blocks == nil || len(blocks) < 1 {
s.logger.Errorf("Wasn't able to read block with sequence number %d from ledger, skipping....", seqNum)
continue
}
blockBytes, err := pb.Marshal(blocks[0])
if err != nil {
s.logger.Errorf("Could not marshal block: %s", err)
}
if err != nil {
s.logger.Errorf("Could not calculate hash of block: %s", err)
}
response.Payloads = append(response.Payloads, &proto.Payload{
SeqNum: seqNum,
Data: blockBytes,
// TODO: Check hash generation for given block from the ledger
Hash: "",
})
}
// Sending back response with missing blocks
msg.Respond(&proto.GossipMessage{
Content: &proto.GossipMessage_StateResponse{response},
})
}