Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

peer需要改变的 #19

Open
yfhk opened this issue Nov 23, 2018 · 6 comments
Open

peer需要改变的 #19

yfhk opened this issue Nov 23, 2018 · 6 comments

Comments

@yfhk
Copy link
Owner

yfhk commented Nov 23, 2018

  1. Gossip()往别人发的时候只往同一个channel的peer发;
  2. fetch的时候,只从同一个channel的peer取;
  3. broadcast的时候给同一个channel的order发送;
    4 .deliver的时候给同一个channel的peer发送;
  4. 跨链调用的逻辑;
  5. 查询某侧链币余额的逻辑(放到手机端来做);
@yfhk
Copy link
Owner Author

yfhk commented Nov 23, 2018

// IsChannelRestricted returns whether this GossipMessage should be routed
// only in its channel
func (m *GossipMessage) IsChannelRestricted() bool {
return m.Tag == GossipMessage_CHAN_AND_ORG || m.Tag == GossipMessage_CHAN_ONLY || m.Tag == GossipMessage_CHAN_OR_ORG
}

@yfhk
Copy link
Owner Author

yfhk commented Nov 23, 2018

fabric/gossip/gossip/gossip_impl.go

@yfhk
Copy link
Owner Author

yfhk commented Nov 23, 2018

func (g *gossipServiceImpl) handleMessage(m proto.ReceivedMessage) {
if g.toDie() {
return
}

if m == nil || m.GetGossipMessage() == nil {
	return
}

msg := m.GetGossipMessage()

g.logger.Debug("Entering,", m.GetConnectionInfo(), "sent us", msg)
defer g.logger.Debug("Exiting")

if !g.validateMsg(m) {
	g.logger.Warning("Message", msg, "isn't valid")
	return
}

if msg.IsChannelRestricted() {
	if gc := g.chanState.lookupChannelForMsg(m); gc == nil {
		// If we're not in the channel, we should still forward to peers of our org
		// in case it's a StateInfo message
		if g.isInMyorg(discovery.NetworkMember{ERC20ADDR: m.GetConnectionInfo().ID}) && msg.IsStateInfoMsg() {
			if g.stateInfoMsgStore.Add(msg) {
				g.emitter.Add(&emittedGossipMessage{
					SignedGossipMessage: msg,
					filter:              m.GetConnectionInfo().ID.IsNotSameFilter,
				})
			}
		}
		if !g.toDie() {
			g.logger.Debug("No such channel", msg.Channel, "discarding message", msg)
		}

@yfhk
Copy link
Owner Author

yfhk commented Nov 23, 2018

// Gossip sends a message to other peers to the network
func (g *gossipServiceImpl) Gossip(msg *proto.GossipMessage) {
// Educate developers to Gossip messages with the right tags.
// See IsTagLegal() for wanted behavior.
if err := msg.IsTagLegal(); err != nil {
panic(errors.WithStack(err))
}

sMsg := &proto.SignedGossipMessage{
	GossipMessage: msg,
}

var err error
if sMsg.IsDataMsg() {
	sMsg, err = sMsg.NoopSign()
} else {
	_, err = sMsg.Sign(func(msg []byte) ([]byte, error) {
		return g.mcs.Sign(msg)
	})
}

if err != nil {
	g.logger.Warningf("Failed signing message: %+v", errors.WithStack(err))
	return
}

if msg.IsChannelRestricted() {
	gc := g.chanState.getGossipChannelByChainID(msg.Channel)
	if gc == nil {
		g.logger.Warning("Failed obtaining gossipChannel of", msg.Channel, "aborting")
		return
	}
	if msg.IsDataMsg() {
		gc.AddToMsgStore(sMsg)
	}
}

@yfhk
Copy link
Owner Author

yfhk commented Nov 23, 2018

http://wutongtree.github.io/translations/Kafka-based-Ordering-Service_zh
从这个里面的图可以看出,OSN不用relay给其他的order节点

@yfhk
Copy link
Owner Author

yfhk commented Nov 23, 2018

// Fetcher interface which defines API to fetch missing
// private data elements
type Fetcher interface {
fetch(dig2src dig2sources) ([]*gossip2.PvtDataElement, error)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant