@rsksmart/rif-storage-pinning v0.2.4
RIF Storage.js Pinning service
Application for providing your storage space on decentralized storage networks to other to use in exchange of RIF Tokens
Table of Contents
Usage
Running on bare metal
Install the package from NPM:
$ npm install @rsksmart/rif-storage-pinningWhen you initialize the Pinning service you need Offer ID. It is address of your account that you will use to create the Offer on the RIF Marketplace. You can either go to the RIF Marketplace directly and follow its guidance on how to set up new Offer, or if you need to set up the Pinning service prior that just use the account address instead here.
Example of usage:
$ rif-pinning init --offerId=0x123456789
$ rif-pinning daemon --provider='ws://localhost:8546' --ipfs='http://localhost:5001' --network=testnet --strategy=blockchainThis will:
- initialize pinning service for given Offer
- start the daemon of the pinning service
- listens only for events for the Offer ID
0x123456789 - use blockchain node for listening on events at
ws://localhost:8546that is connected to testnet network - thanks to
--network testnetwill use predefined deployed smart-contracts on testnet - connects to your locally running IPFS node at
http://localhost:5001
Docker
Currently, the Docker image is not published anywhere, so you have to clone/download this repository first.
Bellow we will describe only deployment using docker-compose, but it is possible to use only Docker image as well.
In the root of the repository create file .env-pinner where you can specify any environmental variable as specified bellow. Example is:
RIFS_OFFER='' # fill in the Offer ID here
RIFS_STRATEGY=blockchain
RIFS_NETWORK=testnet
RIFS_PROVIDER='' # fill in the address of RSKj node
RIFS_COMMS_BOOTSTRAP='' # fill in the address of libp2p bootstrap nodesThen to start the pinning service you can simply run:
$ docker-compose upEnvironmental variables
Pinning service supports following environmental variables:
RIFS_CONFIG(string) - Same like--configflag.RIFS_MARKETPLACE_URL(string) - Marketplace URLRIFS_CONTRACT_ADDR(string) - Specifies address of smart contract to listen the events from. Mainly for development as this is otherwise configured using--networkflag.RIFS_COMMS_TRANSPORT(cache/libp2p) - Defines the transport for commsRIFS_COMMS_BOOTSTRAP_ENABLED(true/false) - Defines if bootstrap should be used. Same as libp2p config'sbootstrap.enabledproperty.RIFS_COMMS_BOOTSTRAP_LIST(array) - Defines an array of multiaddress that the Pinner's libp2p node will use to bootstrap its connectivity. Same as libp2p config'sbootstrap.listproperty.RIFS_DB(string) - Specify the name or path to the data base file.RIFS_IPFS(string) - Same like--ipfsflag.RIFS_NETWORK(testnet|mainnet) - Same like--networkflag.RIFS_OFFER(string) - Specifies Offer Id which the Pinning service should listen on. Same like--offerIdflag.RIFS_STRATEGY(blockchain|marketplace) - Same like--strategyflag.RIFS_PROVIDER(string) - Same like--providerflag.LOG_LEVEL(string) - Same like--logflag.LOG_FILTER(string) - Same like--log-filterflag.LOG_PATH(string) - Same like--log-pathflag.LOG_NO_COLORS(boolean) - if set the output won't be colorized
Commands
rif-pinning agreements
Agreements info
USAGE
$ rif-pinning agreements
OPTIONS
-d, --db=db Name or path to DB file
-p, --pinningStatus=running|backoff|created|finished|errored Filter by pinning status
-s, --status=active|inactive Filter by status
--config=config path to JSON config file to load
--log=error|warn|info|verbose|debug [default: error] what level of information to log
--log-filter=log-filter what components should be logged (+-, chars allowed)
--log-path=log-path log to file, default is STDOUT
--skipPrompt Answer yes for any prompting
EXAMPLES
$ rif-pinning agreements
$ rif-pinning agreements --db myOffer.sqlite
$ rif-pinning agreements --ls -f active
$ rif-pinning agreements --ls -f inactive
$ rif-pinning agreements --ls -f inactive -p pinned
$ rif-pinning agreements --ls -f active -p not-pinnedrif-pinning cleanup
Cleanup pinner files
USAGE
$ rif-pinning cleanup
OPTIONS
-d, --db=db Name or path to DB file
-u, --unpin Unpin all files
--config=config path to JSON config file to load
--log=error|warn|info|verbose|debug [default: error] what level of information to log
--log-filter=log-filter what components should be logged (+-, chars allowed)
--log-path=log-path log to file, default is STDOUT
--skipPrompt Answer yes for any prompting
EXAMPLES
$ rif-pinning cleanup
$ rif-pinning cleanup --db myOffer.sqlite
$ rif-pinning cleanup --unpinrif-pinning daemon
Run pinning service
USAGE
$ rif-pinning daemon
OPTIONS
-d, --db=db Name or path to DB file
-n, --network=testnet|mainnet specifies to which network is the provider connected
-p, --provider=provider URL to blockchain node or Marketplace server
--config=config path to JSON config file to load
--ipfs=ipfs specifies a connection URL to IPFS node. Default is go-ipfs listening
configuration.
--log=error|warn|info|verbose|debug [default: error] what level of information to log
--log-filter=log-filter what components should be logged (+-, chars allowed)
--log-path=log-path log to file, default is STDOUT
--skipPrompt Answer yes for any prompting
--strategy=marketplace|blockchain what type of provider will be used for listening on events. Default is
"marketplace". For blockchain you have to have access to a node that has allowed
eth_getLogs call.
EXAMPLES
$ rif-pinning daemon --strategy=blockchain --provider 'ws://localhost:8546' --ipfs '/ip4/127.0.0.1/tcp/5001' --network
testnet
$ rif-pinning daemon --strategy=marketplace --ipfs 'http://localhost:5001' --network testnetrif-pinning db-migration
DB migration
USAGE
$ rif-pinning db-migration
OPTIONS
-d, --db=db Name or path to DB file
-d, --down Undo db migration
-d, --generate=generate Generate migrations using template [--generate=migration_name]
-m, --migration=migration Migration file
-t, --to=to Migrate to
-u, --up Migrate DB
--config=config path to JSON config file to load
--log=error|warn|info|verbose|debug [default: error] what level of information to log
--log-filter=log-filter what components should be logged (+-, chars allowed)
--log-path=log-path log to file, default is STDOUT
--skipPrompt Answer yes for any prompting
EXAMPLES
$ rif-pinning db --up
$ rif-pinning db --down
$ rif-pinning db --up --to 0-test
$ rif-pinning db --up --migration 01-test --migration 02-test
$ rif-pinning db --up --db ./test.sqlite --to 09-test
$ rif-pinning db --down --db ./test.sqlite --to 09-test
$ rif-pinning db --generate my_first_migrationrif-pinning init
Initialize Pinner service dependencies
USAGE
$ rif-pinning init
OPTIONS
-d, --db=db Name or path to DB file
-o, --offerId=offerId ID of Offer to which should the service listen to
-s, --keySize=keySize [default: 2048] Size of private key that will be used for Peer Identity
-t, --keyType=rsa|ed25519|secp256k1 [default: rsa] Type of private key that will be used for Peer Identity
--config=config path to JSON config file to load
--log=error|warn|info|verbose|debug [default: error] what level of information to log
--log-filter=log-filter what components should be logged (+-, chars allowed)
--log-path=log-path log to file, default is STDOUT
--[no-]override-db Skip the prompt when database exists with used value --override-db/--no-override-db
--skipPrompt Answer yes for any prompting
EXAMPLES
$ rif-pinning init
$ rif-pinning init --offerId 0x123 --db ./relativeOrAbsolutePath/db.sqlite
$ rif-pinning init --db fileName.sqlite
$ rif-pinning init --db ./folderContribute
There are some ways you can make this module better:
- Consult our open issues and take on one of them
- Help our tests reach 100% coverage!
Development
Requirements:
- IPFSv5 and higher
- Ganache
- Node & NPM
Please on how to set up the development environment see Development guide
Tips
- Using the
npm run ipfs:consumerandnpm run ipfs:provideryou can interact with each IPFS node using the standard commands that IPFS supports. - You can interact with the CLI using
npm run binscript from the local folder. - Use RIF Communication PubSub Node to listen on the broadcast events! Only configure the correct Room's name!
License
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago