S5 icon indicating copy to clipboard operation
S5 copied to clipboard

Msgpack Standardization

Open pcfreak30 opened this issue 2 years ago • 4 comments

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 avatar Jan 18 '24 18:01 pcfreak30

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

pcfreak30 avatar Jan 18 '24 18:01 pcfreak30

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 avatar Jan 18 '24 18:01 pcfreak30

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 avatar Jan 18 '24 18:01 pcfreak30

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

pcfreak30 avatar Jan 18 '24 18:01 pcfreak30