Skip to content

Commit

Permalink
use full hash (prysmaticlabs#7416)
Browse files Browse the repository at this point in the history
  • Loading branch information
nisdas authored Oct 2, 2020
1 parent ba01abb commit b589ddd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions beacon-chain/p2p/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ func (s *Service) SubscribeToTopic(topic string, opts ...pubsub.SubOpt) (*pubsub
// Content addressable ID function.
//
// ETH2 spec defines the message ID as:
// message-id: SHA256(message.data)[:8]
// message-id: SHA256(message.data)
func msgIDFunction(pmsg *pubsub_pb.Message) string {
h := hashutil.Hash(pmsg.Data)
return string(h[:8])
return string(h[:])
}

func setPubSubParameters() {
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/p2p/pubsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ func TestMessageIDFunction_HashesCorrectly(t *testing.T) {
msg := [32]byte{'J', 'U', 'N', 'K'}
pMsg := &pubsubpb.Message{Data: msg[:]}
hashedData := hashutil.Hash(pMsg.Data)
msgID := string(hashedData[:8])
msgID := string(hashedData[:])
assert.Equal(t, msgID, msgIDFunction(pMsg), "Got incorrect msg id")
}

0 comments on commit b589ddd

Please sign in to comment.