Skip to content

datafund/util_swarmsync

Repository files navigation

Swarmsync

Swarmsync is a Python script that provides a set of tools for managing files on the Ethereum Swarm network. It allows you to upload, download, check the status of uploaded files, and more. You can also create and manage tags for your uploaded files.

Features

  • Upload files to Ethereum Swarm network
  • Download files from Ethereum Swarm network
  • Check the status of uploaded files using stewardship
  • Create and manage tags for uploaded files
  • Encrypt and pin files during upload
  • Monitor and send Prometheus statistics

Getting Started

Prerequisites

Installation

  1. Clone this repository:

    git clone https://github.com/yourusername/swarmsync.git
    cd swarmsync
  2. Install the required Python packages:

    pip install -r requirements.txt

Usage

Show

You can use the show command to display information about the files you have uploaded and their status.

python swarmsync.py show [options]

Options:

  • -s, --saved-tag: Check the existing/stored tag UID.
  • -t, --tag: Enter a tag UID to fetch information about a specific tag.

Download

To download files from the Ethereum Swarm network, use the download command. You can specify the number of concurrent tasks and the Bee node URL.

python swarmsync.py download [options]

Options:

  • -c, --count: Number of concurrent tasks for downloading.
  • -u, --beeurl: Bee node URL(s) (comma-separated) to connect to.

Check

Use the check command to check if files are retrievable using stewardship or to check the status of a specific tag.

python swarmsync.py check [options]

Options:

  • -c, --count: Number of concurrent tasks for checking.
  • -u, --beeurl: Bee node URL to connect to.

Upload

The upload command allows you to upload files and folders to the Ethereum Swarm network. You can specify the path to the folder, whether to encrypt the data, and more.

python swarmsync.py upload [options]

Options:

  • -p, --path: Path to the folder to be uploaded.
  • -s, --search: Search parameter (e.g., *, *.jpg, somename.txt).
  • -P, --pin: Should files be pinned during upload.
  • -t, --tag: Specify a UID tag for the upload.
  • --no-tag: Disable tagging for the upload.
  • -a, --address: Enter an Ethereum address or hexadecimal string (64 characters).
  • -E, --encrypt: Encrypt data during upload.
  • -r, --reupload: Reupload items that are not retrievable.
  • -d, --deferred: Sets Swarm deferred upload header to False.

Mantaray

The mantaray command allows you to manage a Mantaray index, which is a way to organize and access your files on the Swarm network.

python swarmsync.py mantaray [options]

Options:

  • -c, --count: Number of concurrent tasks for uploading the Mantaray index.
  • -u, --beeurl: Bee node URL(s) (comma-separated) to connect to.

Examples

  • To upload a folder with files and subfolders:

    python swarmsync.py upload -p /path/to/folder
  • To download files from the Ethereum Swarm network:

    python swarmsync.py download -c 5 -u http://yourbeeurl:1633
  • To check the status of uploaded files:

    python swarmsync.py check -c 10 -u http://yourbeeurl:1633
  • To display information about uploaded files and their status:

    python swarmsync.py show responses
  • To create and manage a Mantaray index:

    python swarmsync.py mantaray -u http://yourbeeurl:1633

Additional Options

Swarmsync allows you to configure additional options by modifying the script. These options include the Prometheus statistics endpoint, xBee header usage, and more. Please refer to the script's source code for these advanced configurations.

License

This project is licensed under the MIT License - see the LICENSE file for details.