Fabric Gossip 相关代码

policyManager

Each channel has one policy manager, stored in chainSupport(core/peer/peer.go) chainSupport:

{ Resources: bundle.ChannelConfig() }

 whereas bundle: (common/resrouceconfig/bundle.go) Bundle

bundle.ChannelConfig: (common/channelconfig/bundle.go)Bundle

Construct:

 common/policies/policy.go: NewManagerImpl

Usage: channelPolicyManagerGetter.Manager(channelID).GetPolicy(policyType)

 channelPolicyManagerGetter 

construct:

core/peer/peer.go: NewChannelPolicyManagerGetter

MCS

MessageCryptoService (peer/gossip/mcs.go)

Gossip

Gossip service

    Gossip (Gossip_impl)

        CommServer for communication

    State provider per channel

        1. listens for gossip/state messages (two filters, one for gossip which is handled by gossip layer, other for state which is passed by communication layer)

        2. deliver received blocks (to commit into ledger, received from 1 gossip channel, pull from 3)

        3. pull message from select peers (anti entropy)

        4. handle state request messages (recevied by 1)

New channel join

1. CreateChainFromBlock

    a/ CreateLedger

    b/ createChain (core/peer/peer.go)

        1/

        2/ Consturct bundle resource, which will call Gossip eventer to update configuration

        3/ GetGossipService().InitializeChannel (gossp/service/gossip_service.go:InitializeChannel)

   2. InitChain To install system channels

   3. Broadcast block event The event should be registered by client before

Gossip_impl.go 

one communicate server (gossip/comm/comm_impl.go)

one channelstate (gossip/gossip/chanstate.go) one discovery (gossip/discovery/discovery_impl.go)

gossip/gossip/chanstate.go

set of gossip channel, when new channel join, it will create new gossip channel for it, the gossip channel (gossip/gossip/channel/channel.go) deals with all channel-related messages. It also defines gossipAdapterImpl which enable gossip channel to communicate with gossipServiceImpl

gossip/gossip/channel/channel.go

NewGossipChannel:

gossip/discovery/discovery.go

NetworkMember: peer's representation

Discovery: Represents a discovery module

gossip/gossip/msgstore/msgs.go

MessageStore: adds messages to an internal buffer. It's a buffer, has Time To Live, which when expires, it will be deleted. An invalid_policy is specified to replace messages in buffer when add a new one.

    When a message is received, it might:

       - Be added to the buffer

       - Discarded because of some message already in the buffer (invalidated) -- message is invalidated by other

       - Make a message already in the buffer to be discarded (invalidates) -- message invalidates other

    When a message is invalidated, the invalidationTrigger is invoked on that message.

gossip/gossip/pull/pollstore.go

AnchorPeer

1. Peer join channel updates anchor peer

2. Connect to anchor peer by sending membership request

3. Upon anchor responses, update member ship

4. Anchor peer should define external endpoint (peer.gossip.externalEndpoint) otherwise it peers from different org will not known it (When gossip messages to different orgs, it will check external endpoint of target is exist or not, if not and is alive message then discard it -- gossipBatch)

你可能感兴趣的:(Fabric Gossip 相关代码)