Skip to content

Commit

Permalink
[FAB-17748] Additional ConfigTx doc cleanup (hyperledger#1174)
Browse files Browse the repository at this point in the history
- Adjust line length on godoc examples and constants to fix horizontal
scroll
- Reword constants for ConfigGroup keys

Signed-off-by: Tiffany Harris <[email protected]>
  • Loading branch information
stephyee authored Apr 25, 2020
1 parent 9c50c54 commit 2008674
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 35 deletions.
3 changes: 2 additions & 1 deletion pkg/configtx/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ type Organization struct {
Policies map[string]Policy
MSP MSP

// AnchorPeers contains the endpoints of anchor peers for each application organization.
// AnchorPeers contains the endpoints of anchor peers for each
// application organization.
AnchorPeers []Address
OrdererEndpoints []string
}
Expand Down
37 changes: 19 additions & 18 deletions pkg/configtx/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,35 @@ SPDX-License-Identifier: Apache-2.0

package configtx

import "math"

const (
// These values are fixed for the genesis block.
msgVersion = 0
epoch = 0

defaultHashingAlgorithm = "SHA256"

defaultBlockDataHashingStructureWidth = math.MaxUint32

// ConsortiumKey is the key for the common.ConfigValue for the Consortium message.
// ConsortiumKey is the key for the ConfigValue of a
// Consortium.
ConsortiumKey = "Consortium"

// HashingAlgorithmKey is the common.ConfigValue type key name for the HashingAlgorithm message.
// HashingAlgorithmKey is the key for the ConfigValue of a
// HashingAlgorithm.
HashingAlgorithmKey = "HashingAlgorithm"

// BlockDataHashingStructureKey is the common.ConfigValue type key name for the BlockDataHashingStructure message.
// BlockDataHashingStructureKey is the key for the ConfigValue
// of a BlockDataHashingStructure.
BlockDataHashingStructureKey = "BlockDataHashingStructure"

// OrdererAddressesKey is the common.ConfigValue type key name for the OrdererAddresses message.
// OrdererAddressesKey is the key for the ConfigValue, OrdererAddresses.
OrdererAddressesKey = "OrdererAddresses"

// CapabilitiesKey is the name of the key which refers to capabilities, it appears at the channel,
// application, and orderer levels and this constant is used for all three.
// CapabilitiesKey is the key for the ConfigValue, capabilities.
// CapabiltiesKey can be used at the channel, application, and orderer levels.
CapabilitiesKey = "Capabilities"

// EndpointsKey is the common.ConfigValue key name for the Endpoints message in the OrdererOrgGroup.
// EndpointsKey is the key for the ConfigValue, Endpoints in
// a OrdererOrgGroup.
EndpointsKey = "Endpoints"

// MSPKey is the key for the MSP definition in orderer groups.
// MSPKey is the key for the ConfigValue, MSP.
MSPKey = "MSP"

// AdminsPolicyKey is the key used for the admin policy.
Expand All @@ -51,14 +49,17 @@ const (
// EndorsementPolicyKey is the key used for the endorsement policy.
EndorsementPolicyKey = "Endorsement"

// LifecycleEndorsementPolicyKey is the key used for the lifecycle endorsement policy.
// LifecycleEndorsementPolicyKey is the key used for the lifecycle endorsement
// policy.
LifecycleEndorsementPolicyKey = "LifecycleEndorsement"

// BlockValidationPolicyKey is the key used for the block validation policy in the OrdererOrgGroup.
// BlockValidationPolicyKey is the key used for the block validation policy in
// the OrdererOrgGroup.
BlockValidationPolicyKey = "BlockValidation"

// ChannelCreationPolicyKey is the key used in the consortium config to denote the policy
// to be used in evaluating whether a channel creation request is authorized.
// ChannelCreationPolicyKey is the key used in the consortium config to denote
// the policy to be used in evaluating whether a channel creation request
// is authorized.
ChannelCreationPolicyKey = "ChannelCreationPolicy"

// ChannelGroupKey is the group name for the channel config.
Expand Down
37 changes: 23 additions & 14 deletions pkg/configtx/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ func Example_basic() {
c := configtx.New(baseConfig)

err := c.SetConsortiumChannelCreationPolicy("SampleConsortium",
configtx.Policy{Type: configtx.ImplicitMetaPolicyType, Rule: "MAJORITY Admins"})
configtx.Policy{Type: configtx.ImplicitMetaPolicyType,
Rule: "MAJORITY Admins"})
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -123,7 +124,8 @@ func Example_basic() {
}

// Sign the envelope with the list of signatures
_, err = peer1SigningIdentity.SignConfigUpdateEnvelope(configUpdate, configSignatures...)
_, err = peer1SigningIdentity.SignConfigUpdateEnvelope(configUpdate,
configSignatures...)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -208,10 +210,11 @@ func Example_policies() {
baseConfig := fetchChannelConfig()
c := configtx.New(baseConfig)

err := c.SetApplicationOrgPolicy("Org1", configtx.AdminsPolicyKey, "TestPolicy", configtx.Policy{
Type: configtx.ImplicitMetaPolicyType,
Rule: "MAJORITY Endorsement",
})
err := c.SetApplicationOrgPolicy("Org1", configtx.AdminsPolicyKey, "TestPolicy",
configtx.Policy{
Type: configtx.ImplicitMetaPolicyType,
Rule: "MAJORITY Endorsement",
})
if err != nil {
panic(err)
}
Expand All @@ -226,10 +229,11 @@ func Example_policies() {
panic(err)
}

err = c.SetOrdererOrgPolicy("OrdererOrg", configtx.AdminsPolicyKey, "TestPolicy", configtx.Policy{
Type: configtx.ImplicitMetaPolicyType,
Rule: "MAJORITY Endorsement",
})
err = c.SetOrdererOrgPolicy("OrdererOrg", configtx.AdminsPolicyKey, "TestPolicy",
configtx.Policy{
Type: configtx.ImplicitMetaPolicyType,
Rule: "MAJORITY Endorsement",
})
if err != nil {
panic(err)
}
Expand All @@ -254,12 +258,14 @@ func Example_ordererEndpoints() {
baseConfig := fetchChannelConfig()
c := configtx.New(baseConfig)

err := c.SetOrdererEndpoint("OrdererOrg", configtx.Address{Host: "127.0.0.3", Port: 8050})
err := c.SetOrdererEndpoint("OrdererOrg", configtx.Address{Host: "127.0.0.3",
Port: 8050})
if err != nil {
panic(err)
}

err = c.RemoveOrdererEndpoint("OrdererOrg", configtx.Address{Host: "127.0.0.1", Port: 9050})
err = c.RemoveOrdererEndpoint("OrdererOrg", configtx.Address{Host: "127.0.0.1",
Port: 9050})
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -335,7 +341,8 @@ func ExampleNewSystemChannelGenesisBlock() {
Policies: map[string]configtx.Policy{
configtx.ReadersPolicyKey: {
Type: configtx.SignaturePolicyType,
Rule: "OR('Org1MSP.admin', 'Org1MSP.peer', 'Org1MSP.client')",
Rule: "OR('Org1MSP.admin', 'Org1MSP.peer'," +
"'Org1MSP.client')",
},
configtx.WritersPolicyKey: {
Type: configtx.SignaturePolicyType,
Expand Down Expand Up @@ -451,7 +458,9 @@ func ExampleNewCreateChannelTx() {
},
},
Capabilities: []string{"V1_3"},
ACLs: map[string]string{"event/Block": "/Channel/Application/Readers"},
ACLs: map[string]string{
"event/Block": "/Channel/Application/Readers",
},
Policies: map[string]configtx.Policy{
configtx.ReadersPolicyKey: {
Type: configtx.ImplicitMetaPolicyType,
Expand Down
4 changes: 2 additions & 2 deletions pkg/configtx/msp.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ type MSP struct {
// List of TLS intermediate certificates trusted by this MSP;
// They are returned by GetTLSIntermediateCerts.
TLSIntermediateCerts []*x509.Certificate
// fabric_node_ous contains the configuration to distinguish clients from peers from orderers
// based on the OUs.
// Contains the configuration to distinguish clients
// from peers from orderers based on the OUs.
NodeOus membership.NodeOUs
}

Expand Down

0 comments on commit 2008674

Please sign in to comment.