Giter Club home page Giter Club logo

akasha-gateway's Introduction

Akasha Gateway

Restful HTTP API for the Akasha decentralized social network. Work in progress!

Installation

If you have a local Go development environment set up, the Akasha gateway can be downloaded and built from source with the usual go get workflow. Please note, the gateway contains certain C code too (secp256k1 crypto library) and as such requires a C compiler too.

$ go get -v github.com/karalabe/akasha-gateway

Alternatively, the Akasha gateway is also available as an automated build from Docker Hub. This is based on the Alpine Linux distribution to keep the image size small (12MB download).

$ docker pull karalabe/akasha-gateway

Usage

The Akasha gateway has 3 important options that need to be set:

  • The host name on which the RESTful HTTP API server is listening for remote requests (to advertise the correct URL on the documentation page). This is normally the domain of the machine running the gateway (e.g. akasha.karalabe.com), defaulting to localhost.
  • The port number on which to listen for remote HTTP connections. This is normally set to 80 (requires low-port privileges), defaulting to 8080.
  • The data directory where the Ethereum blockchain and the IPFS caches will end up in. This is normally set to a reliable data partition, defaulting to $HOME/.akasha.

Using the Go binary directly, the above options can be set via command line flags:

$ akasha-gateway --host=akasha.karalabe.com --port=80 --datadir=/my/data/dir

Using docker is a bit more involved, as the port cannot be changed via a flag, rather docker needs to be told to route it differently. As for the data directory, docker needs to explicitly mount an external folder into the container to ensure the data survives a restart:

$ docker run -p 80:8080 -v /my/data/dir:/root/.akasha:rw karalabe/akasha-gateway --host=akasha.karalabe.com

For a list of flags, please consult akasha-gateway --help or docker run karalabe/akasha-gateway --help.

Internals

The Akasha gateway is a combo Ethereum and IPFS node in a single process. It attaches to both networks and serves user requests by retrieving the social network's state from Ethereum and resolves data content from IPFS.

Since IPFS data availability is questionable (posting user goes offline), the Akasha gateway constantly watches the Ethereum network for publish events (post, comment, etc) and tries to prefetch them at the moment of publication (high chance that the user is still online). Any content (prefetched or not) successfully resolved from the IPFS network gets pinned into the local datastore to avoid future resource consumption.

akasha-gateway's People

Contributors

karalabe avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.