I think you misunderstand. I'm not getting an object, I'm getting a key:val of an object.
Heres an example of what I mean:
{
_: {
#: "demo/space",
>: { ... }
},
valueIDontNeed: "fuaigfiydt67f9tq",
valueIWant: "xxxxxxx"
}
if I run await gun.get("demo/space").get("valueIWant")
is gun downloading the whole node, including value I dont need? or is it only getting the value I asked for?
:point_up: Edit: I think you misunderstand. I'm not getting an object, I'm getting a key:val of an object.
Heres an example of what I mean:
{
_: {
#: "demo/space",
>: { ... }
},
importantValue: "xxxxxxx",
irrelevantValue: "fuaigfiydt67f9tq"
}
if I run await gun.get("demo/space").get("importantValue")
is gun downloading the whole node, including the irrelevant value? or is it only getting the value I asked for?
Could someone please help me figure out how this line works and why it might not be received by remote peer.
root.on('out', {'@': msg['#'], '#': root.ask(open), ok: {rtc: {offer: offer, id: opt.pid}}});
I am trying to add ability to to add video and audio streams to existing peer connection in lib/webrtc.js and that requires ability to renegotiate SDP more than one time.
After many attempts the way I am currently trying to do this is to run pc creation part only if there is no existing peer connection, and by calling
open()
if there isonnegotiationneeded
event fired.
@verschmelzen:matrix.org
Thank you for working on this! If you get it sorted out, please submit a PR for lib/webrtc.js
so we can have an example of video + audio! That would be amazing.
Can someone point me to the best working open-source example of gun ACL in 2022?
Do you mean Access Control List? If so, you would use SEA.encrypt()
and SEA.decrypt()
along with SEA.certify()
to create access/read/write policies. https://gun.eco/docs/SEA#certify
probably a simple question.. can some point me to an example of how to use Rad to build create a storage adapter?
All storage adapter examples are here: https://gun.eco/docs/Storage
Good Afternoon, I'm currently trying to set up gun as a p2p backend for my decentralised application. I'm using gun in react and and currently testing my understanding my adding and removing items from a set according to a form input. I retrieve the 'items' set from gun using:
const gunItems = gun.get('items');
Then add a new item to the set by doing:
const newItem = gun.get(keccak256(formData).toString('hex')).put({data: formData})
gunItems.set(newItem);
In this case, I'm creating objects in gun where the key is the hash of the data in the form of hash(data) : {data: formData}.
I'm "deleting" data using:
gunItems.get(keccak256(formData).toString('hex')).put(null);
After adding "a", "b", then deleting "a" and looking at my local storage, I can see that within the items set, hash(a) : null. However, the object hash(a) : {data: "a"} still exists outside of the set. Shouldn't all values associated with hash(a) be null?
root.on('out', {'@': msg['#'], '#': root.ask(open), ok: {rtc: {offer: offer, id: opt.pid}}});
?
@champ5898 We've talked about moving console.log in gun over to an error event handler, but it's lower on the priority list than upgrading gun's DHT. You could potentially turn off all console logging:
let cl = console.log
console.log = {}
// Turn back on:
console.log = cl
But please keep the welcome message unless you are paying for professional support
I'm having a very mysterious bug, where I'm trying to pass a IGunUserInstance around from a factory function to a client function, but the object seems to be mutated when it exits my factory function.
If I return user.get.bind(user)
directly, then there is no problem. But if I return user
(const user = gun.user()
), then the object outside the factory function is different and "loses" the .get
method.
Does this talk to anyone?
function userFactory() {
const user = gun.user()
return new Promise(resolve => {
gun.on('auth', () =>{
console.log(user.get); // fine
resolve(user);
});
});
}
userFactory().then(user => {
console.log(user.get); // undefined
})
const
issues when dealing with JS prototypal inheritance (chains) earlier, so you might be wise to test :)
user
directly (not in a promise), then there is no problem either. I will investigate more later, the problem might be in the framework and not gun.
this
usually being window
or global
but within gun chain it should be the gun
instance
.put(
is dumb simple, .set(
is a convenience wrapper that covers 2+ "array-like" edge cases: Loosely-Ordered Appends & Mathematical Sets (tables), but likewise, requires more understanding to use / checking docs. I'd love if this could be simplified, but like with ACLs, the nature of these things in any system (centralized or not) have nuances to them. Honestly, that is why I prefer more key/value object stores: they're pretty dumb simple & predictable to use.put(formData)
not put({data: formData})
, (B) doing .put(null)
nulls out the LINK to the data (GUN is a graph database), it doesn't null the data itself, unless (C) you serialize your formData as a string? (maybe a bad idea), then when you do .put("the form data")
and later .put(null)
the null overwrites the bytes of the previous string/text, because the data was saved in-place not as a link to another data node.