ethereum / swarm-dapps

Swarm Đapp Examples
98 stars 202 forks source link

PSS messenger dapp #29

Closed aquiladev closed 5 years ago

aquiladev commented 5 years ago

24 #25

cobordism commented 5 years ago

@zelig, @nolash, can you take a look at this?

nolash commented 5 years ago

@aquiladev writing to let you know that I've noticed the submission, but haven't so far had the bandwith to go through it. I hope to get back to you with a review early next week. In the meantime, thank you very much for your contribution.

nolash commented 5 years ago

@aquiladev I've had a look through the submission now, and I have a couple of questions:

Thanks.

aquiladev commented 5 years ago

@nolash

nolash commented 5 years ago

@aquiladev ok I understand, thanks.

I gave it a spin with @justelad and we were able to add each other and exchange messages. So far so good. Some questions regarding the pss implementation:

I'm not qualified to do a proper review of a react app, so @justelad will be taking care of that in the near future.

THanks.

aquiladev commented 5 years ago

Hi @nolash,

  1. I suppose Erebos library handles it
  2. In case of connection lose it will not be restored automatically, the dapp should be refreshed in order to receive/send messages
  3. I will implement formatting (display first and last bytes) with copy-to-clipboard
  4. Where do you think it would be better to set ws endpoint? I can show popup with ws endpoint field on dapp's start
nolash commented 5 years ago
  1. No, it can't because it has no way of knowing. Either the address must be explicitly given by the user, or it would have to be part of the request/response handshake where the peer voluntarily discloses its address. You can specify anything from 0 to 32 bytes of address. The more bytes you specify, the more efficient the routing will be. Right now it's in effect 0 bytes, which means it sends all messages to all peers (along the lines of the basic strategy of whisper). The main point of pss, however, is to provide message routing; a tradeoff of secrecy for efficiency. So could we do either one of the two?

  2. I see. So, if the work is to be continued into "goal 2," I'd prefer if we include in the next step address connection restoration within a session, agree?

  3. Great

  4. Yes, either popup or just a div over the pubkey fields with defaults already filled in that disappears when you click connect. You choose.

Thanks again.

aquiladev commented 5 years ago
  1. Not sure that I fully understood it, I will spend time to investigate it Current implementation: 1) on app start I retrieve base address by pss_baseAddr and public key by pss_getPublicKey 2) send contact request:
    • set peer pss_setPeerPublicKey {receiverPublicKey} {topic}
    • send message pss_sendAsym {receiverPublicKey} {topic} {message}, message contains base address of sender 3) accept request by contact:
    • set peer pss_setPeerPublicKey {senderPublicKey} {topic}
    • send message pss_sendAsym {senderPublicKey} {topic} {message}, message contains base address of receiver 4) exchange messages pss_sendAsym {publicKey} {topic} {message}

Would you please point me to the place regarding the address?

  1. Agree
  2. Done
  3. Done (Pushed changes)
nolash commented 5 years ago

send message pss_sendAsym {senderPublicKey} {topic} {message}, message contains base address of receiver

@aquiladev aha so it is handled in the contact request/response then? The full address of the requester is set with setPeerPublicKey on the receiver, and the requester updates from the address in the response? If it's done like this it's all fine.

... I mean - ideally sliding scale "luminosity," of course, but that's for later :)

nolash commented 5 years ago

HOWEVER - I see in your calls to setPeerPublicKey in /examples/messenger/src/base/messenger.js the address argument is omitted. That translates to an zero-byte address. Even if your application message struct contains the address, there is no software that automagically sets this for you.

nolash commented 5 years ago

Oh and I forgot one more thing:

Could you please remove the leading / in the resource paths? Or are they necessary? Without them the app can be served from a subfolder.

aquiladev commented 5 years ago

@nolash there is no routing, / is not needed and not used

nolash commented 5 years ago

If I put the app on my webserver at localhost/messenger lets say, I get a bunch of 404s when trying to load.

nolash commented 5 years ago

@aquiladev the address stuff seems to work. Good! Curious: If I first send 0x as the address, it gets updated on the response, right?

nolash commented 5 years ago

The websocket popup, if I give an alternate value (port 8547 for example) and press enter, the popup just pops back, if I press the button, it works.

aquiladev commented 5 years ago

@nolash

nolash commented 5 years ago

Great! That's all from me. Thanks :)

aquiladev commented 5 years ago

@justelad I agree that the solution design may look not good, can be heavily improved, but this is example dapp, I think it is not needed here