Skip to content

Commit

Permalink
[FAB-1858] Provide gossip with channel config
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Jason Yellick committed Jan 26, 2017
1 parent b225806 commit 0a94993
Show file tree
Hide file tree
Showing 7 changed files with 308 additions and 355 deletions.
29 changes: 19 additions & 10 deletions core/peer/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var peerLogger = logging.MustGetLogger("peer")

type chainSupport struct {
configtx.Manager
sharedconfig.Descriptor
ledger ledger.PeerLedger
}

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

sharedConfigHandler := sharedconfig.NewDescriptorImpl()

gossipEventer := service.GetGossipService().NewConfigEventer()

gossipCallbackWrapper := func(cm configtx.Manager) {
gossipEventer.ProcessConfigUpdate(&chainSupport{
Manager: cm,
Descriptor: sharedConfigHandler,
})
}

configtxInitializer := configtx.NewInitializer()
configtxInitializer.Handlers()[common.ConfigurationItem_Peer] = sharedConfigHandler
configtxManager, err := configtx.NewManagerImpl(configEnvelope, configtxInitializer, nil)
configtxManager, err := configtx.NewManagerImpl(
configEnvelope,
configtxInitializer,
[]func(cm configtx.Manager){gossipCallbackWrapper},
)
if err != nil {
return err
}
Expand All @@ -178,18 +192,13 @@ func createChain(cid string, ledger ledger.PeerLedger, cb *common.Block) error {
}

cs := &chainSupport{
Manager: configtxManager,
ledger: ledger,
Manager: configtxManager,
Descriptor: sharedConfigHandler,
ledger: ledger,
}

c := committer.NewLedgerCommitter(ledger, txvalidator.NewTxValidator(cs))

// TODO This should be called from a configtx.Manager but it's not
// implemented yet. When it will be, this needs to move there,
// and the inner fields (AnchorPeers) only should be passed to this.
if err := service.GetGossipService().JoinChannel(c, cb); err != nil {
return err
}
service.GetGossipService().InitializeChannel(cs.ChainID(), c)

chains.Lock()
defer chains.Unlock()
Expand Down
147 changes: 0 additions & 147 deletions gossip/service/channel.go

This file was deleted.

180 changes: 0 additions & 180 deletions gossip/service/channel_test.go

This file was deleted.

Loading

0 comments on commit 0a94993

Please sign in to comment.