diff --git a/sharding/shard.go b/sharding/shard.go index 816ca2c84..fb38cc829 100644 --- a/sharding/shard.go +++ b/sharding/shard.go @@ -52,7 +52,7 @@ func (s *Shard) HeaderByHash(hash *common.Hash) (*CollationHeader, error) { return nil, fmt.Errorf("get failed: %v", err) } if encoded == nil { - return nil, fmt.Errorf("no value set for header hash: %v", hash.String()) + return nil, fmt.Errorf("no value set for header hash: %vs", hash.Hex()) } var header CollationHeader @@ -158,10 +158,7 @@ func (s *Shard) SetAvailability(chunkRoot *common.Hash, availability bool) error } else { encoded = []byte{0} } - if err := s.shardDB.Put(key, encoded); err != nil { - return err - } - return nil + return s.shardDB.Put(key, encoded) } // SaveHeader adds the collation header to shardDB. @@ -177,10 +174,7 @@ func (s *Shard) SaveHeader(header *CollationHeader) error { } // uses the hash of the header as the key. - if err := s.shardDB.Put(header.Hash(), encoded); err != nil { - return fmt.Errorf("cannot update shardDB: %v", err) - } - return nil + return s.shardDB.Put(header.Hash(), encoded) } // SaveBody adds the collation body to the shardDB and sets availability. @@ -245,7 +239,7 @@ func (s *Shard) SetCanonical(header *CollationHeader) error { // dataAvailabilityLookupKey formats a string that will become a lookup // key in the shardDB. func dataAvailabilityLookupKey(chunkRoot *common.Hash) common.Hash { - key := fmt.Sprintf("availability-lookup:%s", chunkRoot.String()) + key := fmt.Sprintf("availability-lookup:%s", chunkRoot.Hex()) return common.BytesToHash([]byte(key)) } diff --git a/sharding/shard_test.go b/sharding/shard_test.go index 4c174a200..cd3d90af5 100644 --- a/sharding/shard_test.go +++ b/sharding/shard_test.go @@ -191,8 +191,8 @@ func TestShard_CanonicalHeaderHash(t *testing.T) { t.Errorf("should throw error if a non-existent period, shardID pair is used") } - if canonicalHeaderHash.String() != headerHash.String() { - t.Errorf("header hashes do not match. want=%s. got=%s", headerHash.String(), canonicalHeaderHash.String()) + if canonicalHeaderHash.Hex() != headerHash.Hex() { + t.Errorf("header hashes do not match. want=%s. got=%s", headerHash.Hex(), canonicalHeaderHash.Hex()) } } @@ -337,7 +337,7 @@ func TestShard_CheckAvailability(t *testing.T) { t.Errorf("could not check availability: %v", err) } if !available { - t.Errorf("collation body is not available: chunkRoot=%v, body=%v", header.ChunkRoot(), collation.body) + t.Errorf("collation body is not available: chunkRoot=%s, body=%v", header.ChunkRoot().Hex(), collation.body) } }