From e3f6e586eef99b48ca75dcf5e1f58962acb40331 Mon Sep 17 00:00:00 2001 From: vyzo Date: Mon, 4 May 2020 19:34:30 +0300 Subject: [PATCH] use blake2b hash as the message ID function --- node/modules/lp2p/pubsub.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/node/modules/lp2p/pubsub.go b/node/modules/lp2p/pubsub.go index 15fb39486..95984ddd7 100644 --- a/node/modules/lp2p/pubsub.go +++ b/node/modules/lp2p/pubsub.go @@ -8,6 +8,7 @@ import ( peer "github.com/libp2p/go-libp2p-core/peer" pubsub "github.com/libp2p/go-libp2p-pubsub" pubsub_pb "github.com/libp2p/go-libp2p-pubsub/pb" + blake2b "github.com/minio/blake2b-simd" ma "github.com/multiformats/go-multiaddr" "go.uber.org/fx" @@ -207,6 +208,11 @@ func GossipSub(cfg *config.Pubsub) interface{} { } } +func HashMsgId(m *pubsub_pb.Message) string { + hash := blake2b.Sum256(m.Data) + return string(hash[:]) +} + func newTracerWrapper(tr pubsub.EventTracer) pubsub.EventTracer { return &tracerWrapper{tr: tr} }