How to use dht.PutValue

I’m trying to create a p2p network without having to use the ipfs network,
when doing a put I am not getting it, here is a snippet of the code.

	host, err := libp2p.New(
		libp2p.ListenAddrs(sourceMultiAddr),
		libp2p.Identity(prvKey),
		libp2p.EnableRelay(),
	)
	if err != nil {
		log.Fatalf("Error creating host: %v", err)
	}

	dhtOptions := []dht.Option{
		dht.Mode(dht.ModeServer),
		dht.ProtocolPrefix("/test"),
	}

	dht, err := dht.New(ctx, host, dhtOptions...)
	if err != nil {
		log.Fatalf("Error creating DHT: %v", err)
	}

	value := []byte("Hello World")

	hash, _ := multihash.Sum(value, multihash.SHA2_256, -1)

	cid := cid2.NewCidV1(cid2.Raw, hash)

	err = dht.PutValue(ctx, "/ipns/"+cid.String(), value)
	if err != nil {
		log.Infof("Error putting value in DHT: %v", err)
	}

Error: record could not be unmarshalled

dht.PutValue require validators on the IPFS network only two kinds of values are accepted.
pk that maps hash(publicRsaKey) -> RsaKey and IPNS which maps a peer id to a signed peer id ipns record.

You could make your own DHT network with your own validators.
But the DHT is not stable enough to store data long term (nodes leaves and join the DHT, adding so called “churn”), in IPFS we use it to store peer records which tells you who store some CID, or IPNS records. Both are updated daily by the hosts.

If you talk about your usecase I can give you different ideas.

since already thanks for helping.
Could you tell me another idea to deploy this?

What are you trying to do ?

It has the idea of ​​publishing a file on the p2p network, a peer that is interested in that file will consume it and will publish it, in case it no longer wants to remove that file from its store. The idea of ​​the project is to have a “server” that will publish sequential files in which “clients” could consume and republish. So far the connection with the peers is working, but I can’t use dht to manage the routes.

It has the idea of ​​publishing a file on the p2p network, a peer that is interested in that file will consume it and will publish it, in case it no longer wants to remove that file from its store. The idea of ​​the project is to have a “server” that will publish sequential files in which “clients” could consume and republish. So far the connection with the peers is working, but I can’t use dht to manage the routes.[quote=“Jorropo, post:4, topic:1856, full:true”]
What are you trying to do ?
[/quote]