Skip to content

Commit

Permalink
[FAB-2912] Undo base16-encoding for channel names
Browse files Browse the repository at this point in the history
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 <kostas@christidis.io>
  • Loading branch information
kchristidis committed Mar 29, 2017
1 parent 51b7e85 commit 4515d66
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions orderer/kafka/chain_partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down
2 changes: 1 addition & 1 deletion orderer/kafka/chain_partition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions orderer/multichain/chainsupport.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion orderer/multichain/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 4515d66

Please sign in to comment.