Skip to content

Commit

Permalink
Fix import cycle after merge
Browse files Browse the repository at this point in the history
Despite the verification running and returning positive, the merge seems
to have created an import cycle, this changeset fixes that.

Change-Id: I903766efa524f942d8389bebea27ca0b4e373aa5
Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
  • Loading branch information
Jason Yellick committed Dec 12, 2016
1 parent ea69374 commit 7da2338
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion orderer/multichain/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func TestNewChain(t *testing.T) {
oldConfigEnv := utils.UnmarshalConfigurationEnvelopeOrPanic(oldGenesisTxPayload.Data)

newChainID := "TestNewChain"
newChainMessage := ab.ChainCreationConfigurationTransaction(static.AcceptAllPolicyKey, newChainID, oldConfigEnv)
newChainMessage := utils.ChainCreationConfigurationTransaction(static.AcceptAllPolicyKey, newChainID, oldConfigEnv)

status := manager.ProposeChain(newChainMessage)

Expand Down
3 changes: 2 additions & 1 deletion orderer/multichain/systemchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/hyperledger/fabric/orderer/common/sharedconfig"
cb "github.com/hyperledger/fabric/protos/common"
ab "github.com/hyperledger/fabric/protos/orderer"
"github.com/hyperledger/fabric/protos/utils"

"github.com/golang/protobuf/proto"
)
Expand Down Expand Up @@ -153,7 +154,7 @@ func (sc *systemChain) authorize(configEnvelope *cb.ConfigurationEnvelope) cb.St
return cb.Status_BAD_REQUEST
}

if creationConfigItem.Key != ab.CreationPolicyKey {
if creationConfigItem.Key != utils.CreationPolicyKey {
logger.Debugf("Failing to validate chain creation because first configuration item was not the CreationPolicy")
return cb.Status_BAD_REQUEST
}
Expand Down
8 changes: 4 additions & 4 deletions orderer/multichain/systemchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func TestGoodProposal(t *testing.T) {
ChainID: newChainID,
Type: int32(cb.HeaderType_CONFIGURATION_ITEM),
},
Key: ab.CreationPolicyKey,
Key: utils.CreationPolicyKey,
Type: cb.ConfigurationItem_Orderer,
Value: utils.MarshalOrPanic(&ab.CreationPolicy{
Policy: static.AcceptAllPolicyKey,
Expand Down Expand Up @@ -185,7 +185,7 @@ func TestProposalWithBadPolicy(t *testing.T) {
mcc.ms.mpm.mp = &mockPolicy{}

chainCreateTx := &cb.ConfigurationItem{
Key: ab.CreationPolicyKey,
Key: utils.CreationPolicyKey,
Type: cb.ConfigurationItem_Orderer,
Value: utils.MarshalOrPanic(&ab.CreationPolicy{
Policy: static.AcceptAllPolicyKey,
Expand All @@ -208,7 +208,7 @@ func TestProposalWithMissingPolicy(t *testing.T) {
mcc.ms.msc.chainCreators = []string{static.AcceptAllPolicyKey}

chainCreateTx := &cb.ConfigurationItem{
Key: ab.CreationPolicyKey,
Key: utils.CreationPolicyKey,
Type: cb.ConfigurationItem_Orderer,
Value: utils.MarshalOrPanic(&ab.CreationPolicy{
Policy: static.AcceptAllPolicyKey,
Expand All @@ -232,7 +232,7 @@ func TestProposalWithBadDigest(t *testing.T) {
mcc.ms.msc.chainCreators = []string{static.AcceptAllPolicyKey}

chainCreateTx := &cb.ConfigurationItem{
Key: ab.CreationPolicyKey,
Key: utils.CreationPolicyKey,
Type: cb.ConfigurationItem_Orderer,
Value: utils.MarshalOrPanic(&ab.CreationPolicy{
Policy: static.AcceptAllPolicyKey,
Expand Down
3 changes: 1 addition & 2 deletions orderer/sample_clients/broadcast_config/newchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package main
import (
"github.com/hyperledger/fabric/orderer/common/bootstrap/static"
cb "github.com/hyperledger/fabric/protos/common"
ab "github.com/hyperledger/fabric/protos/orderer"
"github.com/hyperledger/fabric/protos/utils"
)

Expand All @@ -39,5 +38,5 @@ func newChainRequest(creationPolicy, newChainID string) *cb.Envelope {
oldGenesisTxPayload := utils.ExtractPayloadOrPanic(oldGenesisTx)
oldConfigEnv := utils.UnmarshalConfigurationEnvelopeOrPanic(oldGenesisTxPayload.Data)

return ab.ChainCreationConfigurationTransaction(static.AcceptAllPolicyKey, newChainID, oldConfigEnv)
return utils.ChainCreationConfigurationTransaction(static.AcceptAllPolicyKey, newChainID, oldConfigEnv)
}
4 changes: 2 additions & 2 deletions protos/utils/blockutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (

"github.com/golang/protobuf/proto"

"github.com/hyperledger/fabric/orderer/common/cauthdsl"
"github.com/hyperledger/fabric/orderer/common/configtx"
"github.com/hyperledger/fabric/common/cauthdsl"
"github.com/hyperledger/fabric/common/configtx"
cb "github.com/hyperledger/fabric/protos/common"
ab "github.com/hyperledger/fabric/protos/orderer"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package orderer
package utils

import (
cu "github.com/hyperledger/fabric/core/util"
cb "github.com/hyperledger/fabric/protos/common"
"github.com/hyperledger/fabric/protos/utils"
ab "github.com/hyperledger/fabric/protos/orderer"
)

const CreationPolicyKey = "CreationPolicy"
Expand All @@ -34,25 +34,25 @@ func ChainCreationConfiguration(creationPolicy, newChainID string, template *cb.
var hashBytes []byte

for i, item := range template.Items {
configItem := utils.UnmarshalConfigurationItemOrPanic(item.ConfigurationItem)
configItem := UnmarshalConfigurationItemOrPanic(item.ConfigurationItem)
configItem.Header.ChainID = newChainID
newConfigItems[i] = &cb.SignedConfigurationItem{
ConfigurationItem: utils.MarshalOrPanic(configItem),
ConfigurationItem: MarshalOrPanic(configItem),
}
hashBytes = append(hashBytes, newConfigItems[i].ConfigurationItem...)
}

digest := cu.ComputeCryptoHash(hashBytes)

authorizeItem := &cb.SignedConfigurationItem{
ConfigurationItem: utils.MarshalOrPanic(&cb.ConfigurationItem{
ConfigurationItem: MarshalOrPanic(&cb.ConfigurationItem{
Header: &cb.ChainHeader{
ChainID: newChainID,
Type: int32(cb.HeaderType_CONFIGURATION_ITEM),
},
Type: cb.ConfigurationItem_Orderer,
Key: CreationPolicyKey,
Value: utils.MarshalOrPanic(&CreationPolicy{
Value: MarshalOrPanic(&ab.CreationPolicy{
Policy: creationPolicy,
Digest: digest,
}),
Expand All @@ -73,14 +73,14 @@ func ChainCreationConfigurationTransaction(creationPolicy, newChainID string, te
configurationEnvelope := ChainCreationConfiguration(creationPolicy, newChainID, template)

newGenesisTx := &cb.Envelope{
Payload: utils.MarshalOrPanic(&cb.Payload{
Payload: MarshalOrPanic(&cb.Payload{
Header: &cb.Header{
ChainHeader: &cb.ChainHeader{
Type: int32(cb.HeaderType_CONFIGURATION_TRANSACTION),
ChainID: newChainID,
},
},
Data: utils.MarshalOrPanic(configurationEnvelope),
Data: MarshalOrPanic(configurationEnvelope),
}),
}

Expand Down

0 comments on commit 7da2338

Please sign in to comment.