1 Star 0 Fork 0

陈文甲/fabric

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
msg.go 1.58 KB
Copy Edit Raw Blame History
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package comm
import (
"sync"
proto "github.com/hyperledger/fabric/protos/gossip"
"github.com/pkg/errors"
)
// ReceivedMessageImpl is an implementation of ReceivedMessage
type ReceivedMessageImpl struct {
*proto.SignedGossipMessage
lock sync.Locker
conn *connection
connInfo *proto.ConnectionInfo
}
// GetSourceEnvelope Returns the Envelope the ReceivedMessage was
// constructed with
func (m *ReceivedMessageImpl) GetSourceEnvelope() *proto.Envelope {
return m.Envelope
}
// Respond sends a msg to the source that sent the ReceivedMessageImpl
func (m *ReceivedMessageImpl) Respond(msg *proto.GossipMessage) {
sMsg, err := msg.NoopSign()
if err != nil {
err = errors.WithStack(err)
m.conn.logger.Errorf("Failed creating SignedGossipMessage: %+v", err)
return
}
m.conn.send(sMsg, func(e error) {}, blockingSend)
}
// GetGossipMessage returns the inner GossipMessage
func (m *ReceivedMessageImpl) GetGossipMessage() *proto.SignedGossipMessage {
return m.SignedGossipMessage
}
// GetConnectionInfo returns information about the remote peer
// that send the message
func (m *ReceivedMessageImpl) GetConnectionInfo() *proto.ConnectionInfo {
return m.connInfo
}
// Ack returns to the sender an acknowledgement for the message
func (m *ReceivedMessageImpl) Ack(err error) {
ackMsg := &proto.GossipMessage{
Nonce: m.GetGossipMessage().Nonce,
Content: &proto.GossipMessage_Ack{
Ack: &proto.Acknowledgement{},
},
}
if err != nil {
ackMsg.GetAck().Error = err.Error()
}
m.Respond(ackMsg)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/venjia/fabric.git
git@gitee.com:venjia/fabric.git
venjia
fabric
fabric
v1.1.0-preview

Search