@@ -23,9 +23,7 @@ import (
23
23
"github.com/hyperledger/fabric/common/configtx/handlers"
24
24
"github.com/hyperledger/fabric/common/configtx/handlers/msp"
25
25
cb "github.com/hyperledger/fabric/protos/common"
26
- pb "github.com/hyperledger/fabric/protos/peer"
27
26
28
- "github.com/golang/protobuf/proto"
29
27
"github.com/op/go-logging"
30
28
)
31
29
@@ -37,7 +35,8 @@ const (
37
35
var orgSchema = & cb.ConfigGroupSchema {
38
36
Groups : map [string ]* cb.ConfigGroupSchema {},
39
37
Values : map [string ]* cb.ConfigValueSchema {
40
- "MSP" : nil , // TODO, consolidate into a constant once common org code exists
38
+ AnchorPeersKey : nil ,
39
+ handlers .MSPKey : nil , // TODO, consolidate into a constant once common org code exists
41
40
},
42
41
Policies : map [string ]* cb.ConfigPolicySchema {
43
42
// TODO, set appropriately once hierarchical policies are implemented
@@ -48,25 +47,16 @@ var Schema = &cb.ConfigGroupSchema{
48
47
Groups : map [string ]* cb.ConfigGroupSchema {
49
48
"" : orgSchema ,
50
49
},
51
- Values : map [string ]* cb.ConfigValueSchema {
52
- AnchorPeersKey : nil ,
53
- },
50
+ Values : map [string ]* cb.ConfigValueSchema {},
54
51
Policies : map [string ]* cb.ConfigPolicySchema {
55
52
// TODO, set appropriately once hierarchical policies are implemented
56
53
},
57
54
}
58
55
59
- // Peer config keys
60
- const (
61
- // AnchorPeersKey is the key name for the AnchorPeers ConfigValue
62
- AnchorPeersKey = "AnchorPeers"
63
- )
64
-
65
- var logger = logging .MustGetLogger ("peer/sharedconfig" )
56
+ var logger = logging .MustGetLogger ("common/configtx/handlers/application" )
66
57
67
58
type sharedConfig struct {
68
- anchorPeers []* pb.AnchorPeer
69
- orgs map [string ]* handlers.OrgConfig
59
+ orgs map [string ]api.ApplicationOrgConfig
70
60
}
71
61
72
62
// SharedConfigImpl is an implementation of Manager and configtx.ConfigHandler
@@ -86,19 +76,14 @@ func NewSharedConfigImpl(mspConfig *msp.MSPConfigHandler) *SharedConfigImpl {
86
76
}
87
77
}
88
78
89
- // AnchorPeers returns the list of valid orderer addresses to connect to to invoke Broadcast/Deliver
90
- func (di * SharedConfigImpl ) AnchorPeers () []* pb.AnchorPeer {
91
- return di .config .anchorPeers
92
- }
93
-
94
79
// BeginConfig is used to start a new config proposal
95
80
func (di * SharedConfigImpl ) BeginConfig () {
96
81
logger .Debugf ("Beginning a possible new peer shared config" )
97
82
if di .pendingConfig != nil {
98
83
logger .Panicf ("Programming error, cannot call begin in the middle of a proposal" )
99
84
}
100
85
di .pendingConfig = & sharedConfig {
101
- orgs : make (map [string ]* handlers. OrgConfig ),
86
+ orgs : make (map [string ]api. ApplicationOrgConfig ),
102
87
}
103
88
}
104
89
@@ -120,22 +105,15 @@ func (di *SharedConfigImpl) CommitConfig() {
120
105
121
106
// ProposeConfig is used to add new config to the config proposal
122
107
func (di * SharedConfigImpl ) ProposeConfig (key string , configValue * cb.ConfigValue ) error {
123
- switch key {
124
- case AnchorPeersKey :
125
- anchorPeers := & pb.AnchorPeers {}
126
- if err := proto .Unmarshal (configValue .Value , anchorPeers ); err != nil {
127
- return fmt .Errorf ("Unmarshaling error for %s: %s" , key , err )
128
- }
129
- if logger .IsEnabledFor (logging .DEBUG ) {
130
- logger .Debugf ("Setting %s to %v" , key , anchorPeers .AnchorPeers )
131
- }
132
- di .pendingConfig .anchorPeers = anchorPeers .AnchorPeers
133
- default :
134
- logger .Warningf ("Uknown Peer config item with key %s" , key )
135
- }
108
+ logger .Warningf ("Uknown Peer config item with key %s" , key )
136
109
return nil
137
110
}
138
111
112
+ // Organizations returns a map of org ID to ApplicationOrgConfig
113
+ func (di * SharedConfigImpl ) Organizations () map [string ]api.ApplicationOrgConfig {
114
+ return di .config .orgs
115
+ }
116
+
139
117
// Handler returns the associated api.Handler for the given path
140
118
func (pm * SharedConfigImpl ) Handler (path []string ) (api.Handler , error ) {
141
119
if len (path ) == 0 {
@@ -148,8 +126,8 @@ func (pm *SharedConfigImpl) Handler(path []string) (api.Handler, error) {
148
126
149
127
org , ok := pm .pendingConfig .orgs [path [0 ]]
150
128
if ! ok {
151
- org = handlers . NewOrgConfig (path [0 ], pm .mspConfig )
129
+ org = NewApplicationOrgConfig (path [0 ], pm .mspConfig )
152
130
pm .pendingConfig .orgs [path [0 ]] = org
153
131
}
154
- return org , nil
132
+ return org .( * ApplicationOrgConfig ) , nil
155
133
}
0 commit comments