Skip to content

Commit

Permalink
[FAB-2210] Rename CONFIGURATION enums to CONFIG
Browse files Browse the repository at this point in the history
https://jira.hyperledger.org/browse/FAB-2210

All of the config tx protos have been modified to refer to config rather
than to configuration.  This CR extends this pattern to the proto enums.

Change-Id: Ibf4af3d323d009ae5522437dcb660e8750728dc4
Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
  • Loading branch information
Jason Yellick committed Feb 14, 2017
1 parent 4d72057 commit cf887e5
Show file tree
Hide file tree
Showing 22 changed files with 106 additions and 106 deletions.
6 changes: 3 additions & 3 deletions common/configtx/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (st *simpleTemplate) Envelope(chainID string) (*cb.ConfigUpdateEnvelope, er
config, err := proto.Marshal(&cb.ConfigUpdate{
Header: &cb.ChannelHeader{
ChannelId: chainID,
Type: int32(cb.HeaderType_CONFIGURATION_ITEM),
Type: int32(cb.HeaderType_CONFIG),
},
WriteSet: st.configGroup,
})
Expand Down Expand Up @@ -141,7 +141,7 @@ func (ct *compositeTemplate) Envelope(chainID string) (*cb.ConfigUpdateEnvelope,
marshaledConfig, err := proto.Marshal(&cb.ConfigUpdate{
Header: &cb.ChannelHeader{
ChannelId: chainID,
Type: int32(cb.HeaderType_CONFIGURATION_ITEM),
Type: int32(cb.HeaderType_CONFIG),
},
WriteSet: channel,
})
Expand Down Expand Up @@ -192,7 +192,7 @@ func MakeChainCreationTransaction(creationPolicy string, chainID string, signer
LastUpdate: newConfigUpdateEnv,
}

payloadChannelHeader := utils.MakeChannelHeader(cb.HeaderType_CONFIGURATION_TRANSACTION, msgVersion, chainID, epoch)
payloadChannelHeader := utils.MakeChannelHeader(cb.HeaderType_CONFIG, msgVersion, chainID, epoch)
payloadSignatureHeader := utils.MakeSignatureHeader(sSigner, utils.CreateNonceOrPanic())
payloadHeader := utils.MakePayloadHeader(payloadChannelHeader, payloadSignatureHeader)
payload := &cb.Payload{Header: payloadHeader, Data: utils.MarshalOrPanic(newConfigEnv)}
Expand Down
2 changes: 1 addition & 1 deletion common/configtx/tool/provisional/provisional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestGenesisMetadata(t *testing.T) {
t.Fatalf("Expected non-nil metadata")
}

if genesisBlock.Metadata.Metadata[cb.BlockMetadataIndex_LAST_CONFIGURATION] == nil {
if genesisBlock.Metadata.Metadata[cb.BlockMetadataIndex_LAST_CONFIG] == nil {
t.Fatalf("Should have last config set")
}
}
Expand Down
4 changes: 2 additions & 2 deletions common/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (f *factory) Block(chainID string) (*cb.Block, error) {
return nil, err
}

payloadChannelHeader := utils.MakeChannelHeader(cb.HeaderType_CONFIGURATION_TRANSACTION, msgVersion, chainID, epoch)
payloadChannelHeader := utils.MakeChannelHeader(cb.HeaderType_CONFIG, msgVersion, chainID, epoch)
payloadSignatureHeader := utils.MakeSignatureHeader(nil, utils.CreateNonceOrPanic())
payloadHeader := utils.MakePayloadHeader(payloadChannelHeader, payloadSignatureHeader)
payload := &cb.Payload{Header: payloadHeader, Data: utils.MarshalOrPanic(&cb.ConfigEnvelope{LastUpdate: configEnv})}
Expand All @@ -57,7 +57,7 @@ func (f *factory) Block(chainID string) (*cb.Block, error) {
block := cb.NewBlock(0, nil)
block.Data = &cb.BlockData{Data: [][]byte{utils.MarshalOrPanic(envelope)}}
block.Header.DataHash = block.Data.Hash()
block.Metadata.Metadata[cb.BlockMetadataIndex_LAST_CONFIGURATION] = utils.MarshalOrPanic(&cb.Metadata{
block.Metadata.Metadata[cb.BlockMetadataIndex_LAST_CONFIG] = utils.MarshalOrPanic(&cb.Metadata{
Value: utils.MarshalOrPanic(&cb.LastConfig{Index: 0}),
})
return block, nil
Expand Down
2 changes: 1 addition & 1 deletion core/committer/txvalidator/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (v *txValidator) Validate(block *common.Block) error {
logger.Errorf("VSCCValidateTx for transaction txId = %s returned error %s", txID, err)
continue
}
} else if common.HeaderType(payload.Header.ChannelHeader.Type) == common.HeaderType_CONFIGURATION_TRANSACTION {
} else if common.HeaderType(payload.Header.ChannelHeader.Type) == common.HeaderType_CONFIG {
configEnvelope, err := configtx.UnmarshalConfigEnvelope(payload.Data)
if err != nil {
err := fmt.Errorf("Error unmarshaling config which passed initial validity checks: %s", err)
Expand Down
10 changes: 5 additions & 5 deletions core/common/validation/msgvalidation.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func ValidateProposalMessage(signedProp *pb.SignedProposal) (*pb.Proposal, *comm

// continue the validation in a way that depends on the type specified in the header
switch common.HeaderType(hdr.ChannelHeader.Type) {
case common.HeaderType_CONFIGURATION_TRANSACTION:
case common.HeaderType_CONFIG:
//which the types are different the validation is the same
//viz, validate a proposal to a chaincode. If we need other
//special validation for confguration, we would have to implement
Expand Down Expand Up @@ -181,8 +181,8 @@ func validateChannelHeader(cHdr *common.ChannelHeader) error {

// validate the header type
if common.HeaderType(cHdr.Type) != common.HeaderType_ENDORSER_TRANSACTION &&
common.HeaderType(cHdr.Type) != common.HeaderType_CONFIGURATION_ITEM &&
common.HeaderType(cHdr.Type) != common.HeaderType_CONFIGURATION_TRANSACTION {
common.HeaderType(cHdr.Type) != common.HeaderType_CONFIG_UPDATE &&
common.HeaderType(cHdr.Type) != common.HeaderType_CONFIG {
return fmt.Errorf("invalid header type %s", common.HeaderType(cHdr.Type))
}

Expand Down Expand Up @@ -217,7 +217,7 @@ func validateCommonHeader(hdr *common.Header) error {
}

// validateConfigTransaction validates the payload of a
// transaction assuming its type is CONFIGURATION_TRANSACTION
// transaction assuming its type is CONFIG
func validateConfigTransaction(data []byte, hdr *common.Header) error {
putilsLogger.Infof("validateConfigTransaction starts for data %p, header %s", data, hdr)

Expand Down Expand Up @@ -357,7 +357,7 @@ func ValidateTransaction(e *common.Envelope) (*common.Payload, error) {
err = validateEndorserTransaction(payload.Data, payload.Header)
putilsLogger.Infof("ValidateTransactionEnvelope returns err %s", err)
return payload, err
case common.HeaderType_CONFIGURATION_TRANSACTION:
case common.HeaderType_CONFIG:
err = validateConfigTransaction(payload.Data, payload.Header)
putilsLogger.Infof("ValidateTransactionEnvelope returns err %s", err)
return payload, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (v *Validator) ValidateAndPrepareBatch(block *common.Block, doMVCCValidatio
addWriteSetToBatch(txRWSet, committingTxHeight, updates)
valid = true
}
} else if common.HeaderType(payload.Header.ChannelHeader.Type) == common.HeaderType_CONFIGURATION_TRANSACTION {
} else if common.HeaderType(payload.Header.ChannelHeader.Type) == common.HeaderType_CONFIG {
valid, err = v.validateConfigTX(env)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion core/peer/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func getCurrConfigBlockFromLedger(ledger ledger.PeerLedger) (*common.Block, erro
currBlockNumber = block.Header.Number - 1
continue
}
if tx.Header.ChannelHeader.Type == int32(common.HeaderType_CONFIGURATION_TRANSACTION) {
if tx.Header.ChannelHeader.Type == int32(common.HeaderType_CONFIG) {
return block, nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion orderer/common/broadcast/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (bh *handlerImpl) Handle(srv ab.AtomicBroadcast_BroadcastServer) error {
support, ok := bh.sm.GetChain(payload.Header.ChannelHeader.ChannelId)
if !ok {
// Chain not found, maybe create one?
if payload.Header.ChannelHeader.Type != int32(cb.HeaderType_CONFIGURATION_TRANSACTION) {
if payload.Header.ChannelHeader.Type != int32(cb.HeaderType_CONFIG) {
return srv.Send(&ab.BroadcastResponse{Status: cb.Status_NOT_FOUND})
}

Expand Down
2 changes: 1 addition & 1 deletion orderer/common/broadcast/broadcast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func makeConfigMessage(chainID string) *cb.Envelope {
Header: &cb.Header{
ChannelHeader: &cb.ChannelHeader{
ChannelId: chainID,
Type: int32(cb.HeaderType_CONFIGURATION_TRANSACTION),
Type: int32(cb.HeaderType_CONFIG),
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion orderer/common/configtxfilter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (cf *configFilter) Apply(message *cb.Envelope) (filter.Action, filter.Commi
return filter.Forward, nil
}

if msgData.Header == nil || msgData.Header.ChannelHeader == nil || msgData.Header.ChannelHeader.Type != int32(cb.HeaderType_CONFIGURATION_TRANSACTION) {
if msgData.Header == nil || msgData.Header.ChannelHeader == nil || msgData.Header.ChannelHeader.Type != int32(cb.HeaderType_CONFIG) {
return filter.Forward, nil
}

Expand Down
4 changes: 2 additions & 2 deletions orderer/common/configtxfilter/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestAcceptGoodConfig(t *testing.T) {
configEnvBytes := utils.MarshalOrPanic(&cb.ConfigEnvelope{
LastUpdate: configUpdateEnv,
})
configBytes := utils.MarshalOrPanic(&cb.Payload{Header: &cb.Header{ChannelHeader: &cb.ChannelHeader{Type: int32(cb.HeaderType_CONFIGURATION_TRANSACTION)}}, Data: configEnvBytes})
configBytes := utils.MarshalOrPanic(&cb.Payload{Header: &cb.Header{ChannelHeader: &cb.ChannelHeader{Type: int32(cb.HeaderType_CONFIG)}}, Data: configEnvBytes})
configEnvelope := &cb.Envelope{
Payload: configBytes,
}
Expand All @@ -75,7 +75,7 @@ func TestAcceptGoodConfig(t *testing.T) {
func TestRejectBadConfig(t *testing.T) {
cf := NewFilter(&mockconfigtx.Manager{ValidateVal: fmt.Errorf("Error")})
config, _ := proto.Marshal(&cb.ConfigEnvelope{})
configBytes, _ := proto.Marshal(&cb.Payload{Header: &cb.Header{ChannelHeader: &cb.ChannelHeader{Type: int32(cb.HeaderType_CONFIGURATION_TRANSACTION)}}, Data: config})
configBytes, _ := proto.Marshal(&cb.Payload{Header: &cb.Header{ChannelHeader: &cb.ChannelHeader{Type: int32(cb.HeaderType_CONFIG)}}, Data: config})
result, _ := cf.Apply(&cb.Envelope{
Payload: configBytes,
})
Expand Down
2 changes: 1 addition & 1 deletion orderer/multichain/chainsupport.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func (cs *chainSupport) addLastConfigSignature(block *cb.Block) {

lastConfigSignature.Signature = utils.SignOrPanic(cs.signer, util.ConcatenateBytes(lastConfigValue, lastConfigSignature.SignatureHeader, block.Header.Bytes()))

block.Metadata.Metadata[cb.BlockMetadataIndex_LAST_CONFIGURATION] = utils.MarshalOrPanic(&cb.Metadata{
block.Metadata.Metadata[cb.BlockMetadataIndex_LAST_CONFIG] = utils.MarshalOrPanic(&cb.Metadata{
Value: lastConfigValue,
Signatures: []*cb.MetadataSignature{
lastConfigSignature,
Expand Down
2 changes: 1 addition & 1 deletion orderer/multichain/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func TestGetConfigTx(t *testing.T) {
rl.Append(ordererledger.CreateNextBlock(rl, []*cb.Envelope{ctx}))

block := ordererledger.CreateNextBlock(rl, []*cb.Envelope{makeNormalTx(provisional.TestChainID, 7)})
block.Metadata.Metadata[cb.BlockMetadataIndex_LAST_CONFIGURATION] = utils.MarshalOrPanic(&cb.Metadata{Value: utils.MarshalOrPanic(&cb.LastConfig{Index: 7})})
block.Metadata.Metadata[cb.BlockMetadataIndex_LAST_CONFIG] = utils.MarshalOrPanic(&cb.Metadata{Value: utils.MarshalOrPanic(&cb.LastConfig{Index: 7})})
rl.Append(block)

pctx := getConfigTx(rl)
Expand Down
2 changes: 1 addition & 1 deletion orderer/multichain/systemchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func (sc *systemChain) authorizeAndInspect(configTx *cb.Envelope) cb.Status {
return cb.Status_BAD_REQUEST
}

if payload.Header == nil || payload.Header.ChannelHeader == nil || payload.Header.ChannelHeader.Type != int32(cb.HeaderType_CONFIGURATION_TRANSACTION) {
if payload.Header == nil || payload.Header.ChannelHeader == nil || payload.Header.ChannelHeader.Type != int32(cb.HeaderType_CONFIG) {
logger.Debugf("Rejecting chain proposal: Not a config transaction: %s", err)
return cb.Status_BAD_REQUEST
}
Expand Down
2 changes: 1 addition & 1 deletion orderer/multichain/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func makeConfigTxFromConfigUpdateEnvelope(chainID string, configUpdateEnv *cb.Co
payload := &cb.Payload{
Header: &cb.Header{
ChannelHeader: &cb.ChannelHeader{
Type: int32(cb.HeaderType_CONFIGURATION_TRANSACTION),
Type: int32(cb.HeaderType_CONFIG),
ChannelId: chainID,
},
SignatureHeader: &cb.SignatureHeader{},
Expand Down
2 changes: 1 addition & 1 deletion peer/channel/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func executeJoin(cf *ChannelCmdFactory) (err error) {
uuid := cutil.GenerateUUID()

var prop *pb.Proposal
prop, err = putils.CreateProposalFromCIS(uuid, pcommon.HeaderType_CONFIGURATION_TRANSACTION, "", invocation, creator)
prop, err = putils.CreateProposalFromCIS(uuid, pcommon.HeaderType_CONFIG, "", invocation, creator)
if err != nil {
return fmt.Errorf("Error creating proposal for join %s\n", err)
}
Expand Down
Loading

0 comments on commit cf887e5

Please sign in to comment.