Skip to content

Commit 0a94993

Browse files
author
Jason Yellick
committed
[FAB-1858] Provide gossip with channel config
https://jira.hyperledger.org/browse/FAB-1858 This changeset hooks the gossip initialization path into the configtx.Manager path. It utilizes the new callback from configt.Manager to make this event driven. Change-Id: I2491388f97dd1751c31d1aae52c8802be539ea31 Signed-off-by: Jason Yellick <[email protected]>
1 parent b225806 commit 0a94993

File tree

7 files changed

+308
-355
lines changed

7 files changed

+308
-355
lines changed

core/peer/peer.go

+19-10
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ var peerLogger = logging.MustGetLogger("peer")
4444

4545
type chainSupport struct {
4646
configtx.Manager
47+
sharedconfig.Descriptor
4748
ledger ledger.PeerLedger
4849
}
4950

@@ -163,9 +164,22 @@ func createChain(cid string, ledger ledger.PeerLedger, cb *common.Block) error {
163164

164165
sharedConfigHandler := sharedconfig.NewDescriptorImpl()
165166

167+
gossipEventer := service.GetGossipService().NewConfigEventer()
168+
169+
gossipCallbackWrapper := func(cm configtx.Manager) {
170+
gossipEventer.ProcessConfigUpdate(&chainSupport{
171+
Manager: cm,
172+
Descriptor: sharedConfigHandler,
173+
})
174+
}
175+
166176
configtxInitializer := configtx.NewInitializer()
167177
configtxInitializer.Handlers()[common.ConfigurationItem_Peer] = sharedConfigHandler
168-
configtxManager, err := configtx.NewManagerImpl(configEnvelope, configtxInitializer, nil)
178+
configtxManager, err := configtx.NewManagerImpl(
179+
configEnvelope,
180+
configtxInitializer,
181+
[]func(cm configtx.Manager){gossipCallbackWrapper},
182+
)
169183
if err != nil {
170184
return err
171185
}
@@ -178,18 +192,13 @@ func createChain(cid string, ledger ledger.PeerLedger, cb *common.Block) error {
178192
}
179193

180194
cs := &chainSupport{
181-
Manager: configtxManager,
182-
ledger: ledger,
195+
Manager: configtxManager,
196+
Descriptor: sharedConfigHandler,
197+
ledger: ledger,
183198
}
184199

185200
c := committer.NewLedgerCommitter(ledger, txvalidator.NewTxValidator(cs))
186-
187-
// TODO This should be called from a configtx.Manager but it's not
188-
// implemented yet. When it will be, this needs to move there,
189-
// and the inner fields (AnchorPeers) only should be passed to this.
190-
if err := service.GetGossipService().JoinChannel(c, cb); err != nil {
191-
return err
192-
}
201+
service.GetGossipService().InitializeChannel(cs.ChainID(), c)
193202

194203
chains.Lock()
195204
defer chains.Unlock()

gossip/service/channel.go

-147
This file was deleted.

gossip/service/channel_test.go

-180
This file was deleted.

0 commit comments

Comments
 (0)