prysm-pulse/beacon-chain/p2p/pubsub_message_id.go
Preston Van Loon 65e3f3e007 Add pubsub message ID function (#4304)
* add pubsub message ID
* thanks linter
* Update rules_go, gogo protobuf, comment
* Merge branch 'master' into add-msg-fn-id
2019-12-17 05:17:54 +00:00

18 lines
465 B
Go

package p2p
import (
"encoding/base64"
"github.com/libp2p/go-libp2p-pubsub/pb"
"github.com/prysmaticlabs/prysm/shared/hashutil"
)
// Content addressable ID function.
//
// Loosely defined as Base64(sha2(data)) until a formal specification is determined.
// Pending: https://github.com/ethereum/eth2.0-specs/issues/1528
func msgIDFunction(pmsg *pubsub_pb.Message) string {
h := hashutil.FastSum256(pmsg.Data)
return base64.URLEncoding.EncodeToString(h[:])
}