Closed folex closed 10 months ago
The API you have described includes two main methods: get_weight
and add_certificate.
The get_weight
method would allow users to retrieve the weight of a specific peer from the perspective of the host node. The add_certificate
method would allow users to add a certificate that defines weights through a chain of trusts.
One possible use case for this API is a cryptocurrency price oracle, which could gather information from multiple price source services on the Fluence network, retrieve weights from the TrustGraph, and calculate a weighted average based on these weights. This would allow the oracle to make more informed decisions about the reliability of different data sources and provide a more accurate representation of the overall market.
Overall, this API could be a useful tool for services and apps deployed on the Fluence network that need to evaluate data from multiple sources and make decisions about which sources to trust.
use rust_peer::{PeerId, TrustGraph, Certificate};
struct TrustGraphService {
trust_graph: TrustGraph,
}
impl TrustGraphService {
fn new() -> Self {
TrustGraphService {
trust_graph: TrustGraph::new(),
}
}
fn get_weight(&self, peer: &PeerId) -> u32 {
self.trust_graph.get_weight(peer)
}
fn add_certificate(&mut self, certificate: Certificate) {
self.trust_graph.add_certificate(certificate);
}
}
Summary
TrustGraph should be available to query through every node's built-in API.
Possible API could be as follows:
get_weight(peer: PeerId) -> u32
to get weight for a specific peer from host node's point of viewadd_certificate(certificate: Certificate)
to add a certificate that defines weights through chain of TrustsThis service should either be tied to TrustGraph used in Kademlia, so its data is disseminated natively, or provide its own means of data dissemination.
Motivation
TrustGraph stores weight and certificate information which can be useful to compare different services against each other and reason about their relations. This information can be used by services & apps deployed on Fluence to evaluate data coming from different data sources on Fluence Network.
Examples
One example can be a cryptocurrency price oracle. Given that several price source services are deployed on Fluence, oracle can then gather information from them, retrieve weights from trust graph, and calculate weighted average.