From 4515d661899d30140da3b5e78a8d6f9ae4567270 Mon Sep 17 00:00:00 2001 From: Kostas Christidis Date: Tue, 28 Mar 2017 21:12:18 -0400 Subject: [PATCH] [FAB-2912] Undo base16-encoding for channel names https://jira.hyperledger.org/browse/FAB-2912 The Kafka-based orderer would base16-encode channel names as a temporary workaround for escaping illegal characters in Kafka [1]. With the filtering added in FAB-1349 [2], this kind of workaround is not longer needed. This changeset removes the workaround. [1] https://github.com/apache/kafka/blob/trunk/core/src/main/scala/kafka/common/Topic.scala#L29 [2] https://jira.hyperledger.org/browse/FAB-1349 Change-Id: I312222924e41cc8a1cf869c1bb3f650448e2f3d5 Signed-off-by: Kostas Christidis --- orderer/kafka/chain_partition.go | 3 +-- orderer/kafka/chain_partition_test.go | 2 +- orderer/multichain/chainsupport.go | 8 ++++---- orderer/multichain/manager.go | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/orderer/kafka/chain_partition.go b/orderer/kafka/chain_partition.go index 7667ed2bf0b..daaa06d3144 100644 --- a/orderer/kafka/chain_partition.go +++ b/orderer/kafka/chain_partition.go @@ -35,8 +35,7 @@ type chainPartitionImpl struct { // Returns a new chain partition for a given chain ID and partition. func newChainPartition(chainID string, partition int32) ChainPartition { return &chainPartitionImpl{ - // TODO https://github.com/apache/kafka/blob/trunk/core/src/main/scala/kafka/common/Topic.scala#L29 - tpc: fmt.Sprintf("%x", chainID), + tpc: fmt.Sprintf("%s", chainID), prt: partition, } } diff --git a/orderer/kafka/chain_partition_test.go b/orderer/kafka/chain_partition_test.go index f37634224a8..152439e5ee6 100644 --- a/orderer/kafka/chain_partition_test.go +++ b/orderer/kafka/chain_partition_test.go @@ -27,7 +27,7 @@ import ( func TestChainPartition(t *testing.T) { cp := newChainPartition(provisional.TestChainID, rawPartition) - expectedTopic := fmt.Sprintf("%x", provisional.TestChainID) + expectedTopic := fmt.Sprintf("%s", provisional.TestChainID) actualTopic := cp.Topic() if strings.Compare(expectedTopic, actualTopic) != 0 { t.Fatalf("Got the wrong topic, expected %s, got %s instead", expectedTopic, actualTopic) diff --git a/orderer/multichain/chainsupport.go b/orderer/multichain/chainsupport.go index bbfd4bf45cf..78e5be53dc3 100644 --- a/orderer/multichain/chainsupport.go +++ b/orderer/multichain/chainsupport.go @@ -128,13 +128,13 @@ func newChainSupport( // Assuming a block created with cb.NewBlock(), this should not // error even if the orderer metadata is an empty byte slice if err != nil { - logger.Fatalf("Error extracting orderer metadata for chain %x: %s", cs.ChainID(), err) + logger.Fatalf("[channel: %s] Error extracting orderer metadata: %s", cs.ChainID(), err) } - logger.Debugf("Retrieved metadata for tip of chain (block #%d): %+v", cs.Reader().Height()-1, metadata) + logger.Debugf("[channel: %s] Retrieved metadata for tip of chain (block #%d): %+v", cs.ChainID(), cs.Reader().Height()-1, metadata) cs.chain, err = consenter.HandleChain(cs, metadata) if err != nil { - logger.Fatalf("Error creating consenter for chain %x: %s", ledgerResources.ChainID(), err) + logger.Fatalf("[channel: %s] Error creating consenter: %s", cs.ChainID(), err) } return cs @@ -254,7 +254,7 @@ func (cs *chainSupport) WriteBlock(block *cb.Block, committers []filter.Committe err := cs.ledger.Append(block) if err != nil { - logger.Panicf("Could not append block: %s", err) + logger.Panicf("[channel: %s] Could not append block: %s", cs.ChainID(), err) } return block } diff --git a/orderer/multichain/manager.go b/orderer/multichain/manager.go index 5a077351d5c..b9b899717a3 100644 --- a/orderer/multichain/manager.go +++ b/orderer/multichain/manager.go @@ -110,7 +110,7 @@ func NewManagerImpl(ledgerFactory ledger.Factory, consenters map[string]Consente // We delay starting this chain, as it might try to copy and replace the chains map via newChain before the map is fully built defer chain.start() } else { - logger.Debugf("Starting chain: %x", chainID) + logger.Debugf("Starting chain: %s", chainID) chain := newChainSupport(createStandardFilters(ledgerResources), ledgerResources, consenters,