pub trait TopicId {
// Required method
fn id(&self) -> [u8; 32];
}Expand description
Topic ids are announced on the network and used to identify peers with overlapping interests.
Once other peers are discovered who are interested in the same topic id, the application will join the gossip overlay under that identifier.
If an optional sync protocol has been provided, the application will attempt to synchronise past state before entering the gossip overlay.
§Designing topic identifiers for applications
Networked applications, such as p2p systems, usually want to converge to the same state over time so that all users eventually see the same data.
If we’re considering the totality of “all data” the application can create as the “global state”, we might want to categorise it into logical “sub-sections”, especially when the application gets complex. In an example chat application we might not want to sync all chat group data which has ever been created by all peers, but only a subset of the ones our peer is actually a member of.
In this case we could separate the application state into distinct topic identifiers, one for each chat group. Now peers can announce their interest in a specific chat group and only sync that particular data.
§TopicQuery vs. TopicId
Next to topic identifiers p2panda offers a TopicQuery trait which allows for even more
sophisticated “network queries”.
TopicId is a tool for general topic discovery and establishing gossip network overlays.
TopicQuery is a query for sync protocols to ask for a specific piece of information.
Consult the TopicQuery documentation in p2panda-sync for further information.