本文整理汇总了Golang中github.com/hyperledger/fabric/protos.Message类的典型用法代码示例。如果您正苦于以下问题:Golang Message类的具体用法?Golang Message怎么用?Golang Message使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Message类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: signMessageMutating
// signMessage modifies the passed in Message by setting the Signature based upon the Payload.
func (p *PeerImpl) signMessageMutating(msg *pb.Message) error {
if SecurityEnabled() {
sig, err := p.secHelper.Sign(msg.Payload)
if err != nil {
return fmt.Errorf("Error signing Openchain Message: %s", err)
}
// Set the signature in the message
msg.Signature = sig
}
return nil
}
示例2: broadcastConsensusMsg
func (i *Noops) broadcastConsensusMsg(msg *pb.Message) error {
t := &pb.Transaction{}
if err := proto.Unmarshal(msg.Payload, t); err != nil {
return fmt.Errorf("Error unmarshalling payload of received Message:%s.", msg.Type)
}
// Change the msg type to consensus and broadcast to the network so that
// other validators may execute the transaction
msg.Type = pb.Message_CONSENSUS
if logger.IsEnabledFor(logging.DEBUG) {
logger.Debugf("Broadcasting %s", msg.Type)
}
txs := &pb.TransactionBlock{Transactions: []*pb.Transaction{t}}
payload, err := proto.Marshal(txs)
if err != nil {
return err
}
msg.Payload = payload
if errs := i.stack.Broadcast(msg, pb.PeerEndpoint_VALIDATOR); nil != errs {
return fmt.Errorf("Failed to broadcast with errors: %v", errs)
}
return nil
}