yfhk / fabric_log

logs
1 stars 0 forks source link

peer需要改变的 #19

Open yfhk opened 5 years ago

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

// 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 commented 5 years ago

fabric/gossip/gossip/gossip_impl.go

yfhk commented 5 years ago

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 commented 5 years ago

// 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 commented 5 years ago

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

yfhk commented 5 years ago

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