yfhk / fabric_log

logs
1 stars 0 forks source link

ChannelSupportRegistrar 只是某个chanel的 #20

Open yfhk opened 5 years ago

yfhk commented 5 years ago

// ChannelSupportRegistrar provides a way for the Handler to look up the Support for a channel type ChannelSupportRegistrar interface { // BroadcastChannelSupport returns the message channel header, whether the message is a config update // and the channel resources for a message or an error if the message is not a message which can // be processed directly (like CONFIG and ORDERER_TRANSACTION messages) BroadcastChannelSupport(msg cb.Envelope) (cb.ChannelHeader, bool, ChannelSupport, error) }

type handlerImpl struct { sm ChannelSupportRegistrar }

// Handle starts a service thread for a given gRPC connection and services the broadcast connection func (bh *handlerImpl) Handle(srv ab.AtomicBroadcast_BroadcastServer) error { addr := util.ExtractRemoteAddress(srv.Context()) logger.Debugf("Starting new broadcast loop for %s", addr) for { msg, err := srv.Recv() if err == io.EOF { logger.Debugf("Received EOF from %s, hangup", addr) return nil } if err != nil { logger.Warningf("Error reading from %s: %s", addr, err) return err }

yfhk commented 5 years ago

其他的channel上面也会有一个systemchannel

yfhk commented 5 years ago

创建channel的命令只发给一个orderer还是所有的orderer都要执行?

yfhk commented 5 years ago

orderer之间广播?还是由sdk来广播给所有的orderer?

yfhk commented 5 years ago

// Channel gives read only access to the channel configuration type Channel interface { // HashingAlgorithm returns the default algorithm to be used when hashing // such as computing block hashes, and CreationPolicy digests HashingAlgorithm() func(input []byte) []byte

// BlockDataHashingStructureWidth returns the width to use when constructing the
// Merkle tree to compute the BlockData hash
BlockDataHashingStructureWidth() uint32

// OrdererAddresses returns the list of valid orderer addresses to connect to to invoke Broadcast/Deliver
OrdererAddresses() []string

// Capabilities defines the capabilities for a channel
Capabilities() ChannelCapabilities

}

yfhk commented 5 years ago
if isOrdererRequired {
    if len(common.OrderingEndpoint) == 0 {
        orderingEndpoints, err := common.GetOrdererEndpointOfChainFnc(channelID, signer, endorserClient)
        if err != nil {
            return nil, fmt.Errorf("Error getting (%s) orderer endpoint: %s", channelID, err)
        }
        if len(orderingEndpoints) == 0 {
            return nil, fmt.Errorf("Error no orderer endpoint got for %s", channelID)
        }
        logger.Infof("Get chain(%s) orderer endpoint: %s", channelID, orderingEndpoints[0])
        // override viper env
        viper.Set("orderer.address", orderingEndpoints[0])
    }

    broadcastClient, err = common.GetBroadcastClientFnc(channelID)
yfhk commented 5 years ago

从上面看出,只需要一个ip就可以了