github.com/alexdevranger/node-1.8.27@v0.0.0-20221128213301-aa5841e41d2d/swarm/README.md (about)

     1  ## Swarm
     2  
     3  [https://swarm.ethereum.org](https://swarm.ethereum.org)
     4  
     5  Swarm is a distributed storage platform and content distribution service, a native base layer service of the ethereum web3 stack. The primary objective of Swarm is to provide a decentralized and redundant store for dapp code and data as well as block chain and state data. Swarm is also set out to provide various base layer services for web3, including node-to-node messaging, media streaming, decentralised database services and scalable state-channel infrastructure for decentralised service economies.
     6  
     7  [![Travis](https://travis-ci.org/ethereum/go-ethereum.svg?branch=master)](https://travis-ci.org/ethereum/go-ethereum)
     8  [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ethersphere/orange-lounge?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
     9  
    10  ## Table of Contents
    11  
    12  - [Building the source](#building-the-source)
    13  - [Running Swarm](#running-swarm)
    14  - [Documentation](#documentation)
    15  - [Developers Guide](#developers-guide)
    16    - [Go Environment](#development-environment)
    17    - [Vendored Dependencies](#vendored-dependencies)
    18    - [Testing](#testing)
    19    - [Profiling Swarm](#profiling-swarm)
    20    - [Metrics and Instrumentation in Swarm](#metrics-and-instrumentation-in-swarm)
    21  - [Public Gateways](#public-gateways)
    22  - [Swarm Dapps](#swarm-dapps)
    23  - [Contributing](#contributing)
    24  - [License](#license)
    25  
    26  ## Building the source
    27  
    28  Building Swarm requires Go (version 1.10 or later).
    29  
    30      go get -d github.com/alexdevranger/node-1.8.27
    31  
    32      go install github.com/alexdevranger/node-1.8.27/cmd/swarm
    33  
    34  ## Running Swarm
    35  
    36  Going through all the possible command line flags is out of scope here, but we've enumerated a few common parameter combos to get you up to speed quickly on how you can run your own Swarm node.
    37  
    38  To run Swarm you need an Ethereum account. You can create a new account by running the following command:
    39  
    40      gdubx account new
    41  
    42  You will be prompted for a password:
    43  
    44      Your new account is locked with a password. Please give a password. Do not forget this password.
    45      Passphrase:
    46      Repeat passphrase:
    47  
    48  Once you have specified the password, the output will be the Ethereum address representing that account. For example:
    49  
    50      Address: {2f1cd699b0bf461dcfbf0098ad8f5587b038f0f1}
    51  
    52  Using this account, connect to Swarm with
    53  
    54      swarm --bzzaccount <your-account-here>
    55  
    56      # in our example
    57  
    58      swarm --bzzaccount 2f1cd699b0bf461dcfbf0098ad8f5587b038f0f1
    59  
    60  ### Verifying that your local Swarm node is running
    61  
    62  When running, Swarm is accessible through an HTTP API on port 8500.
    63  
    64  Confirm that it is up and running by pointing your browser to http://localhost:8500
    65  
    66  ### Ethereum Name Service resolution
    67  
    68  The Ethereum Name Service is the Ethereum equivalent of DNS in the classic web. In order to use ENS to resolve names to Swarm content hashes (e.g. `bzz://theswarm.eth`), `swarm` has to connect to a `gdubx` instance, which is synced with the Ethereum mainnet. This is done using the `--ens-api` flag.
    69  
    70      swarm --bzzaccount <your-account-here> \
    71            --ens-api '$HOME/.ethereum/gdubx.ipc'
    72  
    73      # in our example
    74  
    75      swarm --bzzaccount 2f1cd699b0bf461dcfbf0098ad8f5587b038f0f1 \
    76            --ens-api '$HOME/.ethereum/gdubx.ipc'
    77  
    78  For more information on usage, features or command line flags, please consult the Documentation.
    79  
    80  ## Documentation
    81  
    82  Swarm documentation can be found at [https://swarm-guide.readthedocs.io](https://swarm-guide.readthedocs.io).
    83  
    84  ## Developers Guide
    85  
    86  ### Go Environment
    87  
    88  We assume that you have Go v1.10 installed, and `GOPATH` is set.
    89  
    90  You must have your working copy under `$GOPATH/src/github.com/alexdevranger/node-1.8.27`.
    91  
    92  Most likely you will be working from your fork of `go-ethereum`, let's say from `github.com/nirname/go-ethereum`. Clone or move your fork into the right place:
    93  
    94  ```
    95  git clone git@github.com:nirname/go-ethereum.git $GOPATH/src/github.com/alexdevranger/node-1.8.27
    96  ```
    97  
    98  ### Vendored Dependencies
    99  
   100  All dependencies are tracked in the `vendor` directory. We use `govendor` to manage them.
   101  
   102  If you want to add a new dependency, run `govendor fetch <import-path>`, then commit the result.
   103  
   104  If you want to update all dependencies to their latest upstream version, run `govendor fetch +v`.
   105  
   106  ### Testing
   107  
   108  This section explains how to run unit, integration, and end-to-end tests in your development sandbox.
   109  
   110  Testing one library:
   111  
   112  ```
   113  go test -v -cpu 4 ./swarm/api
   114  ```
   115  
   116  Note: Using options -cpu (number of cores allowed) and -v (logging even if no error) is recommended.
   117  
   118  Testing only some methods:
   119  
   120  ```
   121  go test -v -cpu 4 ./eth -run TestMethod
   122  ```
   123  
   124  Note: here all tests with prefix TestMethod will be run, so if you got TestMethod, TestMethod1, then both!
   125  
   126  Running benchmarks:
   127  
   128  ```
   129  go test -v -cpu 4 -bench . -run BenchmarkJoin
   130  ```
   131  
   132  ### Profiling Swarm
   133  
   134  This section explains how to add Go `pprof` profiler to Swarm
   135  
   136  If `swarm` is started with the `--pprof` option, a debugging HTTP server is made available on port 6060.
   137  
   138  You can bring up http://localhost:6060/debug/pprof to see the heap, running routines etc.
   139  
   140  By clicking full goroutine stack dump (clicking http://localhost:6060/debug/pprof/goroutine?debug=2) you can generate trace that is useful for debugging.
   141  
   142  ### Metrics and Instrumentation in Swarm
   143  
   144  This section explains how to visualize and use existing Swarm metrics and how to instrument Swarm with a new metric.
   145  
   146  Swarm metrics system is based on the `go-metrics` library.
   147  
   148  The most common types of measurements we use in Swarm are `counters` and `resetting timers`. Consult the `go-metrics` documentation for full reference of available types.
   149  
   150  ```
   151  # incrementing a counter
   152  metrics.GetOrRegisterCounter("network.stream.received_chunks", nil).Inc(1)
   153  
   154  # measuring latency with a resetting timer
   155  start := time.Now()
   156  t := metrics.GetOrRegisterResettingTimer("http.request.GET.time"), nil)
   157  ...
   158  t := UpdateSince(start)
   159  ```
   160  
   161  #### Visualizing metrics
   162  
   163  Swarm supports an InfluxDB exporter. Consult the help section to learn about the command line arguments used to configure it:
   164  
   165  ```
   166  swarm --help | grep metrics
   167  ```
   168  
   169  We use Grafana and InfluxDB to visualise metrics reported by Swarm. We keep our Grafana dashboards under version control at `./swarm/grafana_dashboards`. You could use them or design your own.
   170  
   171  We have built a tool to help with automatic start of Grafana and InfluxDB and provisioning of dashboards at https://github.com/nonsense/stateth , which requires that you have Docker installed.
   172  
   173  Once you have `stateth` installed, and you have Docker running locally, you have to:
   174  
   175  1. Run `stateth` and keep it running in the background
   176  
   177  ```
   178  stateth --rm --grafana-dashboards-folder $GOPATH/src/github.com/alexdevranger/node-1.8.27/swarm/grafana_dashboards --influxdb-database metrics
   179  ```
   180  
   181  2. Run `swarm` with at least the following params:
   182  
   183  ```
   184  --metrics \
   185  --metrics.influxdb.export \
   186  --metrics.influxdb.endpoint "http://localhost:8086" \
   187  --metrics.influxdb.username "admin" \
   188  --metrics.influxdb.password "admin" \
   189  --metrics.influxdb.database "metrics"
   190  ```
   191  
   192  3. Open Grafana at http://localhost:3000 and view the dashboards to gain insight into Swarm.
   193  
   194  ## Public Gateways
   195  
   196  Swarm offers a local HTTP proxy API that Dapps can use to interact with Swarm. The Ethereum Foundation is hosting a public gateway, which allows free access so that people can try Swarm without running their own node.
   197  
   198  The Swarm public gateways are temporary and users should not rely on their existence for production services.
   199  
   200  The Swarm public gateway can be found at https://swarm-gateways.net and is always running the latest `stable` Swarm release.
   201  
   202  ## Swarm Dapps
   203  
   204  You can find a few reference Swarm decentralised applications at: https://swarm-gateways.net/bzz:/swarmapps.eth
   205  
   206  Their source code can be found at: https://github.com/ethersphere/swarm-dapps
   207  
   208  ## Contributing
   209  
   210  Thank you for considering to help out with the source code! We welcome contributions from
   211  anyone on the internet, and are grateful for even the smallest of fixes!
   212  
   213  If you'd like to contribute to Swarm, please fork, fix, commit and send a pull request
   214  for the maintainers to review and merge into the main code base. If you wish to submit more
   215  complex changes though, please check up with the core devs first on [our Swarm gitter channel](https://gitter.im/ethersphere/orange-lounge)
   216  to ensure those changes are in line with the general philosophy of the project and/or get some
   217  early feedback which can make both your efforts much lighter as well as our review and merge
   218  procedures quick and simple.
   219  
   220  Please make sure your contributions adhere to our coding guidelines:
   221  
   222  - Code must adhere to the official Go [formatting](https://golang.org/doc/effective_go.html#formatting) guidelines (i.e. uses [gofmt](https://golang.org/cmd/gofmt/)).
   223  - Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) guidelines.
   224  - Pull requests need to be based on and opened against the `master` branch.
   225  - [Code review guidelines](https://github.com/alexdevranger/node-1.8.27/wiki/Code-Review-Guidelines).
   226  - Commit messages should be prefixed with the package(s) they modify.
   227    - E.g. "swarm/fuse: ignore default manifest entry"
   228  
   229  ## License
   230  
   231  The go-dubxcoin library (i.e. all code outside of the `cmd` directory) is licensed under the
   232  [GNU Lesser General Public License v3.0](https://www.gnu.org/licenses/lgpl-3.0.en.html), also
   233  included in our repository in the `COPYING.LESSER` file.
   234  
   235  The go-ethereum binaries (i.e. all code inside of the `cmd` directory) is licensed under the
   236  [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.en.html), also included
   237  in our repository in the `COPYING` file.