Comments (5)
Peering the 2 instances will work (erm... there's an example of how to do this buried somewhere)
But it may be pretty hard to do this without because it means the adapter has to be aware of changes/modifications to the filesystem, and it would need to know how to do this uniformly across all file systems (browser, cloud, desktop, etc.) which would complicate things pretty quickly.
Without peering, GUN has no way of knowing whether the 2 instances aren't actually separate machines, threads, processes, etc. do you have any clever ideas?
from gun.
If I'm not misunderstanding the issue and example, I believe that the desired use-case is what I did with Gunsafe CLI's sync functionality.
from gun.
I dont know about any of this peering buiness. For my usecase, if I were just able to be authed into multiple users on one instance, I'd be golden
Maybe if the put
function had an option like this:
.put(data, undefined, {opt: {putAsUser: SEApair}})
now that would be perfect
from gun.
I think what you're looking for is GUN's Certify
from gun.
I've stumbled across this issue too when I tried to write unit tests for different gun instances with different users. After reading the localStorage.js I thought it was impossible to sync between two local peers only through the storage layer since gun only read the db once at "create" event (cmiiw). Soon it's confirmed by Mark that it needs peering. I also considered to use SEA.certify()
but it gives me privacy issue for my use case since gun sends the certificate along with the associated public key for every put using it. Though I'm interested to know how to put for multiple user without login or certify.
For now, I just use peering as a workaround. I didn't aware that there's documented example to do this so I implemented my own. :/
Here's what I've come up with.
function makePeerFrom(gun) {
let { mesh, pid } = gun.back("opt"), peer = {
id: pid,
wire: {
send(msg) { if (msg) mesh.hear(msg, peer); }
}
}
return peer
}
function doPeering(gun1, gun2) {
let [peer1, peer2] = [makePeerFrom(gun1), makePeerFrom(gun2)]
let [{mesh: mesh1}, {mesh: mesh2}] = [gun1.back("opt"), gun2.back("opt")]
mesh1.hi(peer2)
mesh2.hi(peer1)
}
I've updated the code from your example with my method, it now prints true
twice.
from gun.
Related Issues (20)
- Gun not working with next.js 14.0.4 HOT 15
- Gun reports all documents always not only changed ones
- Referencing nodes that hold only primitive values HOT 2
- [BUG] Error when importing 'gun/lib/time.js' in nodejs HOT 1
- Use trystero for webrtc (with bittorrent dht signalling) HOT 8
- [BUG] mapping values in gun.user does not work properly HOT 10
- Setup without build tools HOT 3
- Proposal: GUN URIs to universally reference data HOT 3
- Question: How to split and distribute work? HOT 1
- Question: webseed functionality? HOT 1
- Have AI gen some contributor docs, docstrings, comments HOT 13
- node-webcrypto-oss deprecated HOT 3
- [BUG] gun server / nodejs / ERROR: Radisk needs `store.put` interface with `(file, data, cb)`!
- Problems with Node.js Scripts for Push/Pull Operations HOT 1
- not working even in same computer between to tab HOT 2
- MBs of out-of-key objects filling up storage HOT 3
- put events while offline never get synced
- Website docs side bar doesnt close HOT 1
- Unused/Inaccessible import of src/mesh.js (and more)
- "gun.user() is not a function" due to SEA not loading properly HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gun.