Skip to content

Commit 4515d66

Browse files
committed
[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 <[email protected]>
1 parent 51b7e85 commit 4515d66

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

orderer/kafka/chain_partition.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ type chainPartitionImpl struct {
3535
// Returns a new chain partition for a given chain ID and partition.
3636
func newChainPartition(chainID string, partition int32) ChainPartition {
3737
return &chainPartitionImpl{
38-
// TODO https://github.com/apache/kafka/blob/trunk/core/src/main/scala/kafka/common/Topic.scala#L29
39-
tpc: fmt.Sprintf("%x", chainID),
38+
tpc: fmt.Sprintf("%s", chainID),
4039
prt: partition,
4140
}
4241
}

orderer/kafka/chain_partition_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
func TestChainPartition(t *testing.T) {
2828
cp := newChainPartition(provisional.TestChainID, rawPartition)
2929

30-
expectedTopic := fmt.Sprintf("%x", provisional.TestChainID)
30+
expectedTopic := fmt.Sprintf("%s", provisional.TestChainID)
3131
actualTopic := cp.Topic()
3232
if strings.Compare(expectedTopic, actualTopic) != 0 {
3333
t.Fatalf("Got the wrong topic, expected %s, got %s instead", expectedTopic, actualTopic)

orderer/multichain/chainsupport.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ func newChainSupport(
128128
// Assuming a block created with cb.NewBlock(), this should not
129129
// error even if the orderer metadata is an empty byte slice
130130
if err != nil {
131-
logger.Fatalf("Error extracting orderer metadata for chain %x: %s", cs.ChainID(), err)
131+
logger.Fatalf("[channel: %s] Error extracting orderer metadata: %s", cs.ChainID(), err)
132132
}
133-
logger.Debugf("Retrieved metadata for tip of chain (block #%d): %+v", cs.Reader().Height()-1, metadata)
133+
logger.Debugf("[channel: %s] Retrieved metadata for tip of chain (block #%d): %+v", cs.ChainID(), cs.Reader().Height()-1, metadata)
134134

135135
cs.chain, err = consenter.HandleChain(cs, metadata)
136136
if err != nil {
137-
logger.Fatalf("Error creating consenter for chain %x: %s", ledgerResources.ChainID(), err)
137+
logger.Fatalf("[channel: %s] Error creating consenter: %s", cs.ChainID(), err)
138138
}
139139

140140
return cs
@@ -254,7 +254,7 @@ func (cs *chainSupport) WriteBlock(block *cb.Block, committers []filter.Committe
254254

255255
err := cs.ledger.Append(block)
256256
if err != nil {
257-
logger.Panicf("Could not append block: %s", err)
257+
logger.Panicf("[channel: %s] Could not append block: %s", cs.ChainID(), err)
258258
}
259259
return block
260260
}

orderer/multichain/manager.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func NewManagerImpl(ledgerFactory ledger.Factory, consenters map[string]Consente
110110
// We delay starting this chain, as it might try to copy and replace the chains map via newChain before the map is fully built
111111
defer chain.start()
112112
} else {
113-
logger.Debugf("Starting chain: %x", chainID)
113+
logger.Debugf("Starting chain: %s", chainID)
114114
chain := newChainSupport(createStandardFilters(ledgerResources),
115115
ledgerResources,
116116
consenters,

0 commit comments

Comments
 (0)