github.com/amazechain/amc@v0.1.3/internal/p2p/message_id.go (about)

     1  package p2p
     2  
     3  import (
     4  	"github.com/amazechain/amc/common/hash"
     5  	"github.com/amazechain/amc/common/types"
     6  	pubsubpb "github.com/libp2p/go-libp2p-pubsub/pb"
     7  )
     8  
     9  // MsgID is a content addressable ID function.
    10  // `SHA256(message.data)[:20]`.
    11  func MsgID(genesisHash types.Hash, pmsg *pubsubpb.Message) string {
    12  	h := hash.Hash(pmsg.Data)
    13  	return string(h[:20])
    14  }