amark / gun

An open source cybersecurity protocol for syncing decentralized graph data.
https://gun.eco/docs
Other
18.16k stars 1.17k forks source link

Can't get results using memdisk #455

Open sergibondarenko opened 7 years ago

sergibondarenko commented 7 years ago

gun 0.8.9, Node.js-to-Node.js

When using memdisk I get dinos.map().val(cb) results only on the first run. There are no results when I run the script the second time, third ...

trex@beast-cave:~/dev/kibi/sentinl-private$ node mem.js
Hello wonderful person! :) Thanks for using GUN...
j9puawb0ARGuXUqjH2hD
{ _: 
   { '#': 'j9puawb0ARGuXUqjH2hD',
     '>': { statistics: 1510072710154 } },
  statistics: { '#': 'j9puawb1HxeRQLFONuGM' } }
j9puawb8019k9oQ04VpLDtAnN
{ _: 
   { '#': 'j9puawb8019k9oQ04VpLDtAnN',
     '>': { statistics: 1510072710163.001 } },
  statistics: { '#': 'j9puawb9019k9lmTDdF0MOu9t' } }
^C
trex@beast-cave:~/dev/kibi/sentinl-private$ node mem.js
Hello wonderful person! :) Thanks for using GUN...
^C
trex@beast-cave:~/dev/kibi/sentinl-private$ node mem.js
Hello wonderful person! :) Thanks for using GUN...
^C

Source code:

const Gun = require('gun');
require('gun/lib/memdisk');
const gun = new Gun();

const app = gun.get('park');
const dinos = app.get('dinos');

const velociraptor = app.get('velociraptor').put({
  statistics: {
    force: 9,
    speed: 15
  }
});

const trex = app.get('trex').put({
  statistics: {
    force: 25,
    speed: 5
  }
});

dinos.set(velociraptor);
dinos.set(trex);

dinos.map().val((v, k) => {
  console.log(k);
  console.log(v);
});
amark commented 7 years ago

@sergibondarenko you are right, this was a bug with how memdisk interfaced with gun. I have fixed that specific problem in the latest commit on GitHub. Please review and let me know!

sergibondarenko commented 7 years ago

@amark I tried, now I get duplicates when I run the script multiple times. An issue similar to this one https://github.com/amark/gun/issues/454 but the number of results is not increasing, it is unpredictable.

trex@beast-cave:~/dev/cluster-job-queue$ node test_memdisk.js
Hello wonderful person! :) Thanks for using GUN, feel free to ask for help on https://gitter.im/amark/gun and ask StackOverflow questions tagged with 'gun'!
0.8 WARNING! Breaking changes, test that your app works before upgrading! The adapter interface has been upgraded (non-default storage and transport layers probably won't work). Also, `.path()` and `.not()` are outside core and now in 'lib/'.
WARNING! This `file.js` module for gun is intended for local development testing only!
j9zijzwsJhIMu2hXMqRU
{ _:
   { '#': 'j9zijzwsJhIMu2hXMqRU',
     '>': { statistics: 1510657641099 } },
  statistics: { '#': 'j9zijzwtbAjzx8sIjsK6' } }
j9zijskx03tH0Z7EBrrH363
{ _:
   { '#': 'j9zijskx03tH0Z7EBrrH363',
     '>': { statistics: 1510657641103.001 } },
  statistics: { '#': 'j9zijsky01agccDV3XyktB0' } }
j9zijskudVhfz6K5xmwK
{ _:
   { '#': 'j9zijskudVhfz6K5xmwK',
     '>': { statistics: 1510657631597 } },
  statistics: { '#': 'j9zijsku01aEdqLWBsPJSh3' } }
j9zijtoqwNKTxtVuswEb
{ _:
   { '#': 'j9zijtoqwNKTxtVuswEb',
     '>': { statistics: 1510657633033 } },
  statistics: { '#': 'j9zijtoq01ambomqXVEnOVy' } }
j9zijy84ipR7gzhtPv2I
{ _:
   { '#': 'j9zijy84ipR7gzhtPv2I',
     '>': { statistics: 1510657638915 } },
  statistics: { '#': 'j9zijy85SDeeIo267kMc' } }

trex@beast-cave:~/dev/cluster-job-queue$ node test_memdisk.js 
Hello wonderful person! :) Thanks for using GUN, feel free to ask for help on https://gitter.im/amark/gun and ask StackOverflow questions tagged with 'gun'!
0.8 WARNING! Breaking changes, test that your app works before upgrading! The adapter interface has been upgraded (non-default storage and transport layers probably won't work). Also, `.path()` and `.not()` are outside core and now in 'lib/'.
WARNING! This `file.js` module for gun is intended for local development testing only!
j9zik152FAnebHG3i0ga
{ _: 
   { '#': 'j9zik152FAnebHG3i0ga',
     '>': { statistics: 1510657642693 } },
  statistics: { '#': 'j9zik15201aUK4PjbXizZmG' } }
j9zik156NylAaARn1oHC
{ _: 
   { '#': 'j9zik156NylAaARn1oHC',
     '>': { statistics: 1510657642697.001 } },
  statistics: { '#': 'j9zik15602jdnlSRalLEiCA' } }
^C
trex@beast-cave:~/dev/cluster-job-queue$ node test_memdisk.js 
Hello wonderful person! :) Thanks for using GUN, feel free to ask for help on https://gitter.im/amark/gun and ask StackOverflow questions tagged with 'gun'!
0.8 WARNING! Breaking changes, test that your app works before upgrading! The adapter interface has been upgraded (non-default storage and transport layers probably won't work). Also, `.path()` and `.not()` are outside core and now in 'lib/'.
WARNING! This `file.js` module for gun is intended for local development testing only!
j9zik2a4tTMXoEhbZUvJ
{ _: 
   { '#': 'j9zik2a4tTMXoEhbZUvJ',
     '>': { statistics: 1510657644171 } },
  statistics: { '#': 'j9zik2a401aoggKvT1HzPGR' } }
j9zik156NylAaARn1oHC
{ _: 
   { '#': 'j9zik156NylAaARn1oHC',
     '>': { statistics: 1510657644176.001 } },
  statistics: { '#': 'j9zik15602jdnlSRalLEiCA' } }
j9zik152FAnebHG3i0ga
{ _: 
   { '#': 'j9zik152FAnebHG3i0ga',
     '>': { statistics: 1510657642693 } },
  statistics: { '#': 'j9zik15201aUK4PjbXizZmG' } }