gun icon indicating copy to clipboard operation
gun copied to clipboard

How to set all data after peers come back online.

Open kamranmuazzam opened this issue 6 years ago • 0 comments

I was just coding until I noticed something unusual(as it appeared to me). Let me give the code. The following code is for something that works just fine. After that there is of the problem say the peers(1 & 2) are connected to a super-peer(any) and they perform following:

gun.get('something').set('one1'); // from 1 gun.get('something').set('two2'); // from 2 //then on both 1 & 2 gun.get('something').map().on(data=>{console.log(data)}); //output is which is very much expected //one1 //two2 // Yay!!!

Now say the peers(1 & 2) are disconnected and they perform following:

gun.get('anotherthing).set('one1'); // from 1 gun.get('anotherthing).set('two2'); // from 2 // then on 1 gun.get('anotherthing').map().on(data=>{console.log(data)}); //output is which is very much expected //one1 // then on 2 gun.get('anotherthing').map().on(data=>{console.log(data)}); //output is which is very much expected //two2 //Yay!! until now

Now say they come back online(connnect to super-peer) and they both perform:

gun.get('anotherthing').map().on(data=>{console.log(data)}); //output is not what I expected //one1 //Oops!!

My explanation: Probably this is quite expected because of conflict resolution. I can also understand that this might be just fine and alls good. But what I want to ask is that is there any way to store both values in the set or some other method that will do the work.

one1 two2

kamranmuazzam avatar Dec 25 '19 06:12 kamranmuazzam