use blake2b hash as the message ID function

This commit is contained in:
vyzo 2020-05-04 19:34:30 +03:00
parent 1b6f6b295b
commit e3f6e586ee

View File

@ -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}
}