ferristseng / rust-ipfs-api

IPFS HTTP client in Rust
Apache License 2.0
247 stars 68 forks source link

Pubsub message deserialization #67

Closed SionoiS closed 2 years ago

SionoiS commented 3 years ago

Hello!

I'm trying to deserialize message correctly to fix #55. I haven't cracked the from field yet. Probably because PeerIds are now Ed25519 since go-ipfs 0.7.0

I'm not sure if having from, data and seqno as options is necessary. According to the docs those fields are not optional.

Also, where should I put the deserialize functions?

Thanks.

SionoiS commented 3 years ago

So PubSub message now deserialize to;

from -> base58btc peerid ,data -> Vec ,seqno -> usize ,all marked as optional.

I tried to get PeerId as Cid but it's too uncommon. Data as Vec allow arbitrary data to be received.

I will now try to send arbitrary data instead of utf8 text only.

SionoiS commented 3 years ago

Well nevermind..

Ideally ipfs should only i/o multibase encoded strings. For now the user will have to transcode. So I guess I'm done for now.

Let me know what you think!

ferristseng commented 3 years ago

Hi! Thanks for opening this. I'll try to get to it soon!

SionoiS commented 3 years ago

I just notice the failed test. Are empty messages even possible? I would think 'data' may be empty but 'from' and 'seqno' always present.

Maybe add a test for a message with an empty 'data' array. /shrug