Skip to content

Commit 5992373

Browse files
committed
[FAB-1363] Move ChainID method to ConsenterSupport
https://jira.hyperledger.org/browse/FAB-1363 This changeset moves the ChainID() method from the ChainSupport interface to the ConsenterSupport one. What necessitates this move is that the Kafka multichain.Chain object returned/expected by HandleChain(), needs to be able to allocate the resources necessary to keep up with its respective chain when the Start() method is invoked by the multichain manager, as the contract of the Chain interface (defined in chainsupport.go) dictates. Keeping up with the respective chain means that the Kafka multichain.Chain object needs to bring up a producer/consumer that connects to the corresponding chain partition, so it needs to know the chain ID. The only object passed to us during the HandleChain call is an object of type multichain.ConsenterSupport. Therefore, this interface needs to be extended with the ChainID() method. I've noted the need for this during my review of this changeset: https://gerrit.hyperledger.org/r/#/c/2763/ (skip to the comment timestamped 11-27 18:52, and its follow-up comment) If you want to see how this will look in action for the Kafka consenter (coming in a follow-up changeset), please see: https://github.com/kchristidis/fabric/blob/47752ed61fcab1b26207a9e9075c1c793d723912/orderer/kafka/main.go#L128 https://github.com/kchristidis/fabric/blob/47752ed61fcab1b26207a9e9075c1c793d723912/orderer/kafka/main.go#L143 Change-Id: I80590534097a1f4b0f30267ee541a3d3e7f7e3e1 Signed-off-by: Kostas Christidis <[email protected]>
1 parent f42b999 commit 5992373

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

orderer/mocks/multichain/multichain.go

+8
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ type ConsenterSupport struct {
4040

4141
// Batches is the channel which WriteBlock writes data to
4242
Batches chan []*cb.Envelope
43+
44+
// ChainIDVal is the value returned by ChainID()
45+
ChainIDVal string
4346
}
4447

4548
// BlockCutter returns BlockCutterVal
@@ -57,3 +60,8 @@ func (mcs *ConsenterSupport) WriteBlock(data []*cb.Envelope, metadata [][]byte,
5760
logger.Debugf("mockWriter: attempting to write batch")
5861
mcs.Batches <- data
5962
}
63+
64+
// ChainID returns the chain ID this specific consenter instance is associated with
65+
func (mcs *ConsenterSupport) ChainID() string {
66+
return mcs.ChainIDVal
67+
}

orderer/multichain/chainsupport.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ type ConsenterSupport interface {
6060
BlockCutter() blockcutter.Receiver
6161
SharedConfig() sharedconfig.Manager
6262
WriteBlock(data []*cb.Envelope, metadata [][]byte, committers []filter.Committer)
63+
ChainID() string // ChainID returns the chain ID this specific consenter instance is associated with
6364
}
6465

6566
// ChainSupport provides a wrapper for the resources backing a chain
@@ -68,9 +69,6 @@ type ChainSupport interface {
6869
deliver.Support
6970
ConsenterSupport
7071

71-
// ChainID returns the ChainID for this chain support
72-
ChainID() string
73-
7472
// ConfigTxManager returns the corresponding configtx.Manager for this chain
7573
ConfigTxManager() configtx.Manager
7674
}

0 commit comments

Comments
 (0)