@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
14
14
limitations under the License.
15
15
*/
16
16
17
- package chainconfig
17
+ package channel
18
18
19
19
import (
20
20
"fmt"
@@ -45,75 +45,58 @@ const (
45
45
SHA3Shake256 = "SHAKE256"
46
46
)
47
47
48
- var logger = logging .MustGetLogger ("common/chainconfig" )
49
-
50
- // Descriptor stores the common chain config
51
- // It is intended to be the primary accessor of DescriptorImpl
52
- // It is intended to discourage use of the other exported DescriptorImpl methods
53
- // which are used for updating the chain config by the configtx.Manager
54
- type Descriptor interface {
55
- // HashingAlgorithm returns the default algorithm to be used when hashing
56
- // such as computing block hashes, and CreationPolicy digests
57
- HashingAlgorithm () func (input []byte ) []byte
58
-
59
- // BlockDataHashingStructureWidth returns the width to use when constructing the
60
- // Merkle tree to compute the BlockData hash
61
- BlockDataHashingStructureWidth () uint32
62
-
63
- // OrdererAddresses returns the list of valid orderer addresses to connect to to invoke Broadcast/Deliver
64
- OrdererAddresses () []string
65
- }
48
+ var logger = logging .MustGetLogger ("configtx/handlers/chainconfig" )
66
49
67
50
type chainConfig struct {
68
51
hashingAlgorithm func (input []byte ) []byte
69
52
blockDataHashingStructureWidth uint32
70
53
ordererAddresses []string
71
54
}
72
55
73
- // DescriptorImpl is an implementation of Manager and configtx.ConfigHandler
56
+ // SharedConfigImpl is an implementation of Manager and configtx.ConfigHandler
74
57
// In general, it should only be referenced as an Impl for the configtx.Manager
75
- type DescriptorImpl struct {
58
+ type SharedConfigImpl struct {
76
59
pendingConfig * chainConfig
77
60
config * chainConfig
78
61
}
79
62
80
- // NewDescriptorImpl creates a new DescriptorImpl with the given CryptoHelper
81
- func NewDescriptorImpl () * DescriptorImpl {
82
- return & DescriptorImpl {
63
+ // NewSharedConfigImpl creates a new SharedConfigImpl with the given CryptoHelper
64
+ func NewSharedConfigImpl () * SharedConfigImpl {
65
+ return & SharedConfigImpl {
83
66
config : & chainConfig {},
84
67
}
85
68
}
86
69
87
70
// HashingAlgorithm returns a function pointer to the chain hashing algorihtm
88
- func (pm * DescriptorImpl ) HashingAlgorithm () func (input []byte ) []byte {
71
+ func (pm * SharedConfigImpl ) HashingAlgorithm () func (input []byte ) []byte {
89
72
return pm .config .hashingAlgorithm
90
73
}
91
74
92
75
// BlockDataHashingStructure returns the width to use when forming the block data hashing structure
93
- func (pm * DescriptorImpl ) BlockDataHashingStructureWidth () uint32 {
76
+ func (pm * SharedConfigImpl ) BlockDataHashingStructureWidth () uint32 {
94
77
return pm .config .blockDataHashingStructureWidth
95
78
}
96
79
97
80
// OrdererAddresses returns the list of valid orderer addresses to connect to to invoke Broadcast/Deliver
98
- func (pm * DescriptorImpl ) OrdererAddresses () []string {
81
+ func (pm * SharedConfigImpl ) OrdererAddresses () []string {
99
82
return pm .config .ordererAddresses
100
83
}
101
84
102
85
// BeginConfig is used to start a new config proposal
103
- func (pm * DescriptorImpl ) BeginConfig () {
86
+ func (pm * SharedConfigImpl ) BeginConfig () {
104
87
if pm .pendingConfig != nil {
105
88
logger .Panicf ("Programming error, cannot call begin in the middle of a proposal" )
106
89
}
107
90
pm .pendingConfig = & chainConfig {}
108
91
}
109
92
110
93
// RollbackConfig is used to abandon a new config proposal
111
- func (pm * DescriptorImpl ) RollbackConfig () {
94
+ func (pm * SharedConfigImpl ) RollbackConfig () {
112
95
pm .pendingConfig = nil
113
96
}
114
97
115
98
// CommitConfig is used to commit a new config proposal
116
- func (pm * DescriptorImpl ) CommitConfig () {
99
+ func (pm * SharedConfigImpl ) CommitConfig () {
117
100
if pm .pendingConfig == nil {
118
101
logger .Panicf ("Programming error, cannot call commit without an existing proposal" )
119
102
}
@@ -122,7 +105,7 @@ func (pm *DescriptorImpl) CommitConfig() {
122
105
}
123
106
124
107
// ProposeConfig is used to add new config to the config proposal
125
- func (pm * DescriptorImpl ) ProposeConfig (configItem * cb.ConfigItem ) error {
108
+ func (pm * SharedConfigImpl ) ProposeConfig (configItem * cb.ConfigItem ) error {
126
109
if configItem .Type != cb .ConfigItem_CHAIN {
127
110
return fmt .Errorf ("Expected type of ConfigItem_Chain, got %v" , configItem .Type )
128
111
}
0 commit comments