I am creating an interactive experience for an exhibition, to showcase community consensus in an abstract way. I am trying to use Helia to do so, as decentralisation is a key part of the exhibition.
The goal would be to have participants enter a frontend webpage and vote for their favourite colour, then the votes would be stored in a datastore on the IPFS network, and continuously pulled to another frontend site to show the community colour rankings.
I am practicing with the helia examples, using the ‘helia-script-tag’ specifically (unmodified so far), and have managed to publish data to the IPFS network from a webpage. I am wondering how to set up a specific datastore for the votes to be added to, and which datastore is the best choice for this. I am also wondering how to fetch the data from that same datastore to display on a webpage.
The way I’d do this is have one peer listen on pubsub for votes from peers, letting each peer get a vote each. Log all the data however you choose, publish the data by creating a CID and sharing it to the peers after votes complete.
I hope I understood the question correctly! (and welcome!!)
You could use welo for this. However it doesn’t sound like zzzync (offline sync) would be very useful here.
For your case libp2p pubsub and helia, both using an indexedDB datastore would be fine. You would need to build a replication protocol and store the total votes locally on each device. Instead of having separate sites for the display and the input, you could have a single site which starts the helia/libp2p instance and queries peers for the updates. The display node and the input clients would all run the same code.
feel free to message me for specifics on what’s needed to build this.
Hey @Tabcat,
Thank you for your suggestion, I am using pubsub and libp2p now, and have opted to have a single site containing both the voting and ranking.
For the pubsub part, I am using a modified version of the helia-script-tag example:
let heliaInstance = null
const instantiateHeliaNode = async () => {
// application-specific data lives in the datastore
const datastore = new DatastoreCore.MemoryDatastore()
const blockstore = new BlockstoreCore.MemoryBlockstore()
if (heliaInstance != null) {
return heliaInstance
}
heliaInstance = await Helia.createHelia({
datastore,
blockstore,
libp2p: {
services: {
pubsub: gossipsub(
{emitSelf:true},
)
}
}
})
addToLog('Created Helia instance')
return heliaInstance
}
And when running the Helia node I seem to be connecting to the same three pairs and only discovering six in total, compared to the hundreds I discover when running the unmodified helia-script-tag example.
Do you (or anyone else) have any idea what would cause that?