codiak / socialarchive-dapp

Dapp built on Swarm to back-up and interact with Twitter data.
GNU General Public License v3.0
2 stars 3 forks source link

Show recently archived backups #33

Closed ameer-clara closed 2 years ago

ameer-clara commented 2 years ago

Out of the list below, reviewed Swarm Feeds and PSS.

PSS is quite interesting, it allows for subscribing to a topic to get real time push updates via websockets, however, it requires running a local server to get certain info, such as address. We should revisit it sometime in the future.

For reading and writing profiles (when uploading archive)

Screen Shot 2022-02-03 at 2 44 28 AM

Implement using Swarm Feeds and Single Owner Chunks (soc)

Algo

upload (4 network calls - probably more behind the scenes)

  1. upload bundle and get hash

    bee.uploadFile
    returns <Reference> 
    {
    reference: hash
    }
  2. upload feed with hash^ and get feed index

    feedWriter.upload(stamp, hash);
    feedReader.download()
    returns {
    feedIndex: "0000000000000005"
    ...
    }
  3. upload profile by adding feedIndex^ to topic

    const profile = {
    timestamp,
    name,
    username,
    hash,
    bio,
    profileImage, // converted to ascii art :)
    };
    topic.writeUInt16LE(feedIndex, 0);
    socWriter.upload(stamp, topic, compress(profile)); // payload restriction of 4096 bytes

browse (1 + n network calls)

  1. get latest feedIndex
    feedReader.download();
    returns {
    feedIndex: "0000000000000006"
    ...
    }
  2. download profiles by using feed index
    for (index === feedIndex; index>0; index--)
    topic.writeUInt16LE(index, 0);
    decompress(socReader.download(topic));

See #62 for cache details