Operation - wcgcyx/fcr GitHub Wiki

Operation

There are three fundemental roles in an FCR network:

  1. Retrieval provider

  2. Payment provider

  3. Retreival client

Operate as a retrieval provider

To operate FCR as a retrieval provider, you will need to:

  1. Set policy for receiving payment

You will first need to set the policy for minimum settlement time.

Every payment channel is supposed to be long-lived in FCR network. Having a minimum settlement time is like having a commitment to other nodes that you will never settle the channel before the settlement time.

FCR has a built-in functionality to prevent you from settling a channel early, but if you tried to settle the channel before the minimum settlement time via other methods, you will likely to be blocked by other nodes as this will be tracked by other nodes.

Also, having a long enough settlment time will encourage others to use the service from you. It is recommended that you have a minimum settlement time of 14 days or more.

For example, to set the minimum settlement time for everyone with a default 336 hours (14 days), use:

fcr paynet policy settle set 1 default 336h

Check here for more policy related functions.

  1. Import & Serve pieces

You will then need to import and serve pieces.

  • If you have regular file to import
fcr cidnet piece import [filepath]

FCR will return the cid imported.

  • If you have .CAR file to import
fcr cidnet piece import-car [filepath]

FCR will return the cid imported.

  • If you are running a filecoin storage miner with fast-retrieve enabled. You can choose to import the unsealed sector copy into the system.
fcr cidnet piece import-sector [filepath, copy]

FCR will return a list of cids imported from this sector.

Note: You can choose to store only the reference to the sector without creating additional copy by passing false into the copy field. However, you cannot move/relocate the sector after doing so as FCR will not be able to load the sector file.

Once you imported the piece, you can serve the piece to the network by:

fcr cidnet serving serve [cid, currency id, ppb]

The ppb stands for price-per-byte and it is in attoFIL.

  1. Claim payment

To this point, you are serving content to the network. As long as other nodes are retrieving from you, you will be able to get the payment.

To check the payment channel status, use:

fcr paynet paych active-in list -l

OR

fcr paynet paych inactive-in list -l

When a channel is active, you can not settle and claim the payment. However, once a channel is inactive, you can then update and settle the channel by:

fcr paynet paych update [currency id, peer addr, paych addr]
fcr paynet paych settle [currency id, peer addr, paych addr]

After 12 hours, you can collect the channel balance by:

fcr paynet paych collect [currency id, peer addr, paych addr]

Once you collect a channel, it will be removed from the storage.

Operate as a payment provider

To operate FCR as the payment provider, you will need to:

  1. Set policy for incoming payment traffic

You will first need to set the policy for minimum settlement time.

For example, to set the minimum settlement time for everyone with a default 336 hours (14 days), use:

fcr paynet policy settle set 1 default 336h

You will then need to set reservation policy. This is to prevent attacks from malicious users.

For example, to set a reservation policy for everyone to at most use 10,000,000 attoFIL at one time:

fcr paynet policy reserve set 1 default 10000000

Check here for more policy related functions.

  1. Create payment channels to popular retrieval providers

You will first need to query for the minimum settlement time committed by the provider:

fcr paynet paych query [currency id, peer addr]

FCR will return a payment channel offer with minimum settlement time.

You can then create a payment channel by:

fcr paynet paych create [paych offer, amount]

For a trust-worthy retrieval provider and a long settlement time, you can set a relatively large amount. Amount is in the unit of attoFIL. (1 FIL = 10^18 attoFIL or 1000000000000000000 attoFIL)

FCR will return the payment channel created.

  1. Serve the channel to the network. Finally you can serve the channel by:
fcr paynet serving serve [currency id, peer addr, paych addr, ppp, period]

Here, ppp stands for payment per period and period stands for period. For example, to charge others 5% for proxy payment, use ppp=5 and period=100.

Operate as a retrieval client

To operate as a retreival client. You just need to first establish a payment channel with either:

A popular retrieval provider so that you can retrieve directly from it.

OR

A popular payment provider so you can retrieve from the network with proxy payment.

To do this, you need to first query for the minimum settlement time commited by the provider:

fcr paynet paych query [currency id, peer addr]

FCR will return a payment channel offer with minimum settlement time.

You can then create a payment channel by:

fcr paynet paych create [paych offer, amount]

For a trust-worthy provider and a long settlement time, you can set a relatively large amount. Amount is in the unit of attoFIL. (1 FIL = 10^18 attoFIL or 1000000000000000000 attoFIL)

Then, you can retrieve from the network. Fast-retrieve would be the best way to do this:

fcr fast-retrieve [cid, outpath, currency id, max amount]