Skip to content

Commit

Permalink
[FAB-2397] Move org config to common Proposer
Browse files Browse the repository at this point in the history
https://jira.hyperledger.org/browse/FAB-2397

This is the another in a series of changesets migrating the individual
config handlers to the common Proposer root structure to eliminate
duplicated code.

Change-Id: I0836d019e58a0e8edc9ab236480be2f1571b81f6
Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
  • Loading branch information
Jason Yellick committed Mar 7, 2017
1 parent b609bf0 commit 2541878
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 223 deletions.
148 changes: 0 additions & 148 deletions common/configvalues/channel/common/organization/organization.go

This file was deleted.

This file was deleted.

15 changes: 7 additions & 8 deletions common/configvalues/root/applicationorg.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"fmt"

api "github.com/hyperledger/fabric/common/configvalues"
"github.com/hyperledger/fabric/common/configvalues/channel/common/organization"
mspconfig "github.com/hyperledger/fabric/common/configvalues/msp"
cb "github.com/hyperledger/fabric/protos/common"
pb "github.com/hyperledger/fabric/protos/peer"
Expand All @@ -42,7 +41,7 @@ type applicationOrgConfig struct {
// SharedConfigImpl is an implementation of Manager and configtx.ConfigHandler
// In general, it should only be referenced as an Impl for the configtx.Manager
type ApplicationOrgConfig struct {
*organization.OrgConfig
*OrganizationGroup
pendingConfig *applicationOrgConfig
config *applicationOrgConfig

Expand All @@ -52,8 +51,8 @@ type ApplicationOrgConfig struct {
// NewSharedConfigImpl creates a new SharedConfigImpl with the given CryptoHelper
func NewApplicationOrgConfig(id string, mspConfig *mspconfig.MSPConfigHandler) *ApplicationOrgConfig {
return &ApplicationOrgConfig{
OrgConfig: organization.NewOrgConfig(id, mspConfig),
config: &applicationOrgConfig{},
OrganizationGroup: NewOrganizationGroup(id, mspConfig),
config: &applicationOrgConfig{},
}
}

Expand All @@ -72,14 +71,14 @@ func (oc *ApplicationOrgConfig) BeginValueProposals(groups []string) ([]api.Valu
logger.Panicf("Programming error, cannot call begin in the middle of a proposal")
}
oc.pendingConfig = &applicationOrgConfig{}
return oc.OrgConfig.BeginValueProposals(groups)
return oc.OrganizationGroup.BeginValueProposals(groups)
}

// RollbackProposals is used to abandon a new config proposal
func (oc *ApplicationOrgConfig) RollbackProposals() {
logger.Debugf("Rolling back proposed org config")
oc.pendingConfig = nil
oc.OrgConfig.RollbackProposals()
oc.OrganizationGroup.RollbackProposals()
}

// CommitProposals is used to commit a new config proposal
Expand All @@ -90,7 +89,7 @@ func (oc *ApplicationOrgConfig) CommitProposals() {
}
oc.config = oc.pendingConfig
oc.pendingConfig = nil
oc.OrgConfig.CommitProposals()
oc.OrganizationGroup.CommitProposals()
}

// ProposeValue is used to add new config to the config proposal
Expand All @@ -106,7 +105,7 @@ func (oc *ApplicationOrgConfig) ProposeValue(key string, configValue *cb.ConfigV
}
oc.pendingConfig.anchorPeers = anchorPeers.AnchorPeers
default:
return oc.OrgConfig.ProposeValue(key, configValue)
return oc.OrganizationGroup.ProposeValue(key, configValue)
}

return nil
Expand Down
3 changes: 1 addition & 2 deletions common/configvalues/root/orderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"time"

api "github.com/hyperledger/fabric/common/configvalues"
"github.com/hyperledger/fabric/common/configvalues/channel/common/organization"
"github.com/hyperledger/fabric/common/configvalues/msp"
ab "github.com/hyperledger/fabric/protos/orderer"
)
Expand Down Expand Up @@ -80,7 +79,7 @@ func NewOrdererGroup(mspConfig *msp.MSPConfigHandler) *OrdererGroup {

// NewGroup returns an Org instance
func (og *OrdererGroup) NewGroup(name string) (api.ValueProposer, error) {
return organization.NewOrgConfig(name, og.mspConfig), nil
return NewOrganizationGroup(name, og.mspConfig), nil
}

func (og *OrdererGroup) Allocate() Values {
Expand Down
Loading

0 comments on commit 2541878

Please sign in to comment.