lotus-cpr

command module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2020 License: Unlicense Imports: 41 Imported by: 0

README

lotus-cpr

A smart caching proxy for Lotus filecoin nodes.

Overview

Lotus-cpr provides a read-only subset of the Lotus RPC API suitable for querying the state of the Filecoin network. Immutable blocks are cached locally for fast retrieval using gonudb and many IO intensive RPC methods can be served without calling Lotus. Fronting Lotus with Lotus-cpr can reduce load on the node, reducing the chance that it falls behind when syncing with the Filecoin chain.

Usage

Install using:

go get -u github.com/iand/lotus-cpr

Lotus-cpr uses a multi-tier caching system. By default no caching is performed and requests are forwarded directly to the Lotus node.

Caching is enabled by specifying a database directory using the --store parameter. When set Lotus-cpr will look for blocks in this database before fetching from upstream. Any blocks retrieved from an upstream source will be stored in the database to satisfy future requests.

To further reduce load on the Lotus node blocks may also be retrived from a blockstore webserver serving block data via HTTP. Use the --blockstore-base parameter to specify the base URL of the blockstore. When enabled Lotus-cpr will consult the local database first, then the blockstore and finally revert to direct node access.

                          +-----------+               +-----------+                  +-----------+
                          |           |               |           |                  |           |
client --- json/rpc ----> | lotus-cpr | -- block? --> |   gondb   | -+--- http ----> |   Store   | 
                          |           |               |           |  |               |           |
                          +-----------+               +-----------+  |               +-----------+
                                |                                    |
                                |                                    |               +-----------+
                                |                                    |               |           |
                                +---------- proxy call --------------+- json/rpc --> |   Lotus   | 
                                                                                     |           |
                                                                                     +-----------+

The gonudb and blockstore caches only store immutable block data and Lotus-cpr will only attempt to use this data when it is sure that the request requires no other state.

Lotus-cpr expects blockstores to make raw data for blocks available using the following URL pattern:

{base_url}/{block_cid}/data.raw

Command line options:

  • --api (required) Multiaddress of Lotus node (default: "/ip4/127.0.0.1/tcp/1234/http")
  • --api-token (required) OAuth token for Lotus node
  • --listen (required) Address to start the RPC server on (default: ":33111")
  • --store (optional) Path to directory containing gonudb store used to cache blocks.
  • --blockstore-baseurl (optional) URL of http server containing blocks from the filecoin chain.

Author

Written by:

License

This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. For more information, see http://unlicense.org/ or the accompanying UNLICENSE file.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL