s5-dev / S5

Decentralized content-addressed storage network
https://docs.sfive.net
MIT License
55 stars 7 forks source link

Msgpack Standardization #24

Open pcfreak30 opened 8 months ago

pcfreak30 commented 8 months ago

A lot of the current metadata formats have some awkward formatting that need to be resolved.

This should serve as a tracking issue for them all

pcfreak30 commented 8 months ago

In JSON, a web app stores its files as objects of objects, but in msgpack its a list of objects.

pcfreak30 commented 8 months ago

A spec should state all file names/keys in a web app or directory should be sorted from A to Z.

Many hash map quirks between Dart and other languages need to be accounted for.

pcfreak30 commented 8 months ago

Example design bug:

      final connectionUrisCount = u.unpackInt()!;

            peer.connectionUris.clear();
            for (int i = 0; i < connectionUrisCount; i++) {
              peer.connectionUris.add(Uri.parse(u.unpackString()!));
            }

u.unpackInt and arraylen arent the same. Need to stop creating custom array or map structures

Another example:

 async sendPublicPeersToPeer(peer: Peer, peersToSend: Peer[]): Promise<void> {
    const p = new Packer();
    p.packInt(protocolMethodAnnouncePeers);

    p.packInt(peersToSend.length);
    for (const pts of peersToSend) {
      p.packBinary(Buffer.from(pts.id.bytes));
      p.packBool(pts.isConnected);
      p.packInt(pts.connectionUris.length);
      for (const uri of pts.connectionUris) {
        p.packString(uri.toString());
      }
    }
    peer.sendMessage(await this.signMessageSimple(p.takeBytes()));
  }
pcfreak30 commented 8 months ago

I would also recommend abstracting all these into message classes similar to https://git.lumeweb.com/LumeWeb/libs5-go/src/branch/develop/protocol.