Open chris-asl opened 5 years ago
Hello @chris-asl
Thanks for reaching out. We currently do not support that use case with upcalls
. However, I am willing to discuss a proposal for implementing it.
@vasco-santos thanks for the reply! In the meantime I have been digging around the code, and was thinking whether the validators, which if I got this right, run at each node that stores the value, can be used as upcalls.
Thus, allowing the application on top of libp2p-kad-dht
decide whether or not to save the value (probably by cb(Error('no store'))
from the validator).
So, the validator
is responsible for validating if the record is valid under certain conditions (we receive a function). The selector
is responsible for selecting which occurrence from a record is the best one.
At a first glimpse, I believe that we could add a new function parameter, such as the validator
and selector
that could notice upwards
that a key was stored (I am not sure about a good naming yet). This sounds a reasonable approach as we would only notice if the application adds that function, and consequently, only who wants to use this will use.
I want to use
libp2p-kad-dht
as a DHT for an application.I am wondering if there's a way to inform this application for new keys about to be saved (or even saved already), i.e. if upcalls are supported.
Example: Given 3 nodes, A, B and C, that run my application which uses
libp2p-kad-dht
.Given a
put(keyX, valueY)
issued by the application of node A and that the value should be stored in node C, is there a way for informing the application of node C, that a<key, value>
is about to be stored?