当前位置: 首页>>代码示例>>Golang>>正文


Golang protos.Message类代码示例

本文整理汇总了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
}
开发者ID:tuand27613,项目名称:fabric,代码行数:12,代码来源:peer.go

示例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
}
开发者ID:C0rWin,项目名称:fabric,代码行数:23,代码来源:noops.go


注:本文中的github.com/hyperledger/fabric/protos.Message类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。