Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem 6: the upvote seems not replicated to the second machine #6

Open
raphael10-collab opened this issue Oct 27, 2021 · 4 comments

Comments

@raphael10-collab
Copy link

raphael10-collab commented Oct 27, 2021

(PC):

(base) raphy@pc:~/hypercore/p2p-multiwriter-with-autobase/solutions/06$ hrepl hypernews.js 
Autobase setup. Pass this to run this same setup in another instance:

hrepl hypernews.js -n 97526323adf7b9c4 -w 97526323adf7b9c40f72daa280646051d539b757e4b03cf5a3e8b3c5f8defac0 -i 68919658e1f6ffb83c013145fcd21c8323f636203cf427e16934e1a24a5d700c

To use another storage directory use --storage ./another
To disable swarming add --no-swarm

API: hypernews (object)
> await hypernews.post('hello world')
> await hypernews.post('sup earth')
> await hypernews.upvote('ef72c47db2a417b486c04a1b823eec2f95f2e3d373395b3bbdf80cbaf0a8aed5')
> .log hypernews.all()
try { for await (const data of hypernews.all()) console.log(data) } catch { console.log(hypernews.all()) }
{
  hash: 'b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9',
  votes: 0,
  data: 'hello world'
}
{
  hash: 'ef72c47db2a417b486c04a1b823eec2f95f2e3d373395b3bbdf80cbaf0a8aed5',
  votes: 1,
  data: 'sup earth'
}

(laptop):

(base) marco@marco-U36SG:~/hypercore/p2p-multiwriter-with-autobase/solutions/06$ hrepl hypernews.js -n 97526323adf7b9c4 -w 97526323adf7b9c40f72daa280646051d539b757e4b03cf5a3e8b3c5f8defac0 -i 68919658e1f6ffb83c013145fcd21c8323f636203cf427e16934e1a24a5d700c
Autobase setup. Pass this to run this same setup in another instance:

hrepl hypernews.js -n 97526323adf7b9c4 -w 625eded7547fcb00ada55031c09343614cb01569d1b1e5484d971d5c35be37f0 -w 97526323adf7b9c40f72daa280646051d539b757e4b03cf5a3e8b3c5f8defac0 -i adeb6b3e1b220495cc13b684af5880660250f48a1065881a1812a9b52c5861e2 -i 68919658e1f6ffb83c013145fcd21c8323f636203cf427e16934e1a24a5d700c

To use another storage directory use --storage ./another
To disable swarming add --no-swarm

API: hypernews (object)
> .log hypernews.all()
try { for await (const data of hypernews.all()) console.log(data) } catch { console.log(hypernews.all()) }
{
  hash: 'b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9',
  votes: 0,
  data: 'hello world'
}
{
  hash: 'ef72c47db2a417b486c04a1b823eec2f95f2e3d373395b3bbdf80cbaf0a8aed5',
  votes: 0,
  data: 'sup earth'
}
> 

It seems that the upvote is not replicated to the second machine

@mafintosh
Copy link
Contributor

Make sure you are running the same code bith places, otherwise try to log in your apply method to make sure it’s running

@raphael10-collab
Copy link
Author

Actually now I'm experiencing something else:

(PC):

(base) raphy@pc:~/hypercore/p2p-multiwriter-with-autobase/solutions/06$ hrepl hypernews.js 
Autobase setup. Pass this to run this same setup in another instance:

hrepl hypernews.js -n da62a6e703b5db20 -w da62a6e703b5db20601e7b17dd6774609e505476cd1a89a898f995e7968b44d0 -i 569612cbe8e33b250b358fa470ec13fb268ed6c544d4d9ecbb0133964081f762

To use another storage directory use --storage ./another
To disable swarming add --no-swarm

API: hypernews (object)

(laptop):

    (base) marco@marco-U36SG:~/hypercore/p2p-multiwriter-with-autobase/solutions/06$ hrepl hypernews.js -n 97526323adf7b9c4 -w 97526323adf7b9c40f72daa280646051d539b757e4b03cf5a3e8b3c5f8defac0 -i 68919658e1f6ffb83c013145fcd21c8323f636203cf427e16934e1a24a5d700c
    Autobase setup. Pass this to run this same setup in another instance:
    
    hrepl hypernews.js -n 97526323adf7b9c4 -w 625eded7547fcb00ada55031c09343614cb01569d1b1e5484d971d5c35be37f0 -w 97526323adf7b9c40f72daa280646051d539b757e4b03cf5a3e8b3c5f8defac0 -i adeb6b3e1b220495cc13b684af5880660250f48a1065881a1812a9b52c5861e2 -i 68919658e1f6ffb83c013145fcd21c8323f636203cf427e16934e1a24a5d700c
    
    To use another storage directory use --storage ./another
    To disable swarming add --no-swarm
    
    API: hypernews (object)

> await hypernews.post('hello world')
> await hypernews.post('sup earth')
> .log hypernews.all()
try { for await (const data of hypernews.all()) console.log(data) } catch { console.log(hypernews.all()) }
{
  hash: 'b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9',
  votes: 0,
  data: 'hello world'
}
{
  hash: 'ef72c47db2a417b486c04a1b823eec2f95f2e3d373395b3bbdf80cbaf0a8aed5',
  votes: 0,
  data: 'sup earth'
}

(PC) :

> await hypernews.post('neptun')
> .log hypernews.all()
try { for await (const data of hypernews.all()) console.log(data) } catch { console.log(hypernews.all()) }
{
  hash: 'd8d5b6772c8f27e1fb4ba0da2bec23394febaa95280037af45a7fed058a5e189',
  votes: 0,
  data: 'neptun'
}

Question : why in (PC) I see only 'neptun' and not 'sup earth' and 'hello world' as well?

(PC) :

> await hypernews.upvote('d8d5b6772c8f27e1fb4ba0da2bec23394febaa95280037af45a7fed058a5e189')
> .log hypernews.all()
try { for await (const data of hypernews.all()) console.log(data) } catch { console.log(hypernews.all()) }
{
  hash: 'd8d5b6772c8f27e1fb4ba0da2bec23394febaa95280037af45a7fed058a5e189',
  votes: 1,
  data: 'neptun'
}

(laptop):

> .log hypernews.all()
try { for await (const data of hypernews.all()) console.log(data) } catch { console.log(hypernews.all()) }
{
  hash: 'b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9',
  votes: 0,
  data: 'hello world'
}
{
  hash: 'd8d5b6772c8f27e1fb4ba0da2bec23394febaa95280037af45a7fed058a5e189',
  votes: 1,
  data: 'neptun'
}
{
  hash: 'ef72c47db2a417b486c04a1b823eec2f95f2e3d373395b3bbdf80cbaf0a8aed5',
  votes: 0,
  data: 'sup earth'
}

This time the upvote for 'neptun' is replicated from PC to laptop
But still I do not understand why with .log hypernews.all() on PC I see only 'neptun'

@mafintosh
Copy link
Contributor

You have to add the writers to the pc, run the command the laptop prints out there

@raphael10-collab
Copy link
Author

So....

I added to the pc:

(base) raphy@pc:~/hypercore/p2p-multiwriter-with-autobase/solutions/06$ hrepl hypernews.js -n da62a6e703b5db20 -w e4de0f19785657603d0acedc4618eb388c1d20200092577baa4639d0a9f0ec59 -w da62a6e703b5db20601e7b17dd6774609e505476cd1a89a898f995e7968b44d0 -i 51038d62d0025cd8a50d6bb6a457381578167af932cb429fcb62c5cb098fcd0f -i 569612cbe8e33b250b358fa470ec13fb268ed6c544d4d9ecbb0133964081f762

And now:

(base) raphy@pc:~/hypercore/p2p-multiwriter-with-autobase/solutions/06$ hrepl hypernews.js -n da62a6e703b5db20 -w e4de0f19785657603d0acedc4618eb388c1d20200092577baa4639d0a9f0ec59 -w da62a6e703b5db20601e7b17dd6774609e505476cd1a89a898f995e7968b44d0 -i 51038d62d0025cd8a50d6bb6a457381578167af932cb429fcb62c5cb098fcd0f -i 569612cbe8e33b250b358fa470ec13fb268ed6c544d4d9ecbb0133964081f762
Autobase setup. Pass this to run this same setup in another instance:

hrepl hypernews.js -n da62a6e703b5db20 -w da62a6e703b5db20601e7b17dd6774609e505476cd1a89a898f995e7968b44d0 -w e4de0f19785657603d0acedc4618eb388c1d20200092577baa4639d0a9f0ec59 -i 569612cbe8e33b250b358fa470ec13fb268ed6c544d4d9ecbb0133964081f762 -i 51038d62d0025cd8a50d6bb6a457381578167af932cb429fcb62c5cb098fcd0f

To use another storage directory use --storage ./another
To disable swarming add --no-swarm

API: hypernews (object)
> .log hypernews.all()
try { for await (const data of hypernews.all()) console.log(data) } catch { console.log(hypernews.all()) }
{
  hash: '27756f050e14a1cb1c1ee867f0eace9ea4d9fcb81b8bee089469f1ebd5fd7b17',
  votes: 2,
  data: 'sun'
}
{
  hash: 'b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9',
  votes: 0,
  data: 'hello world'
}
{
  hash: 'd8d5b6772c8f27e1fb4ba0da2bec23394febaa95280037af45a7fed058a5e189',
  votes: 1,
  data: 'neptun'
}
{
  hash: 'ef72c47db2a417b486c04a1b823eec2f95f2e3d373395b3bbdf80cbaf0a8aed5',
  votes: 0,
  data: 'sup earth'
}

I thought once started for the first time the app on PC and connect to it by the laptop that the one-to-one communication between the laptop and pc was done.

But may be I need to add this extra step: to add to the PC the writers printed out by the laptop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants