EOS Storage Contract API
This issue uses TOK to represent the native token of the blockchain:
The following messages are implemented by the storage contract:
tok::transfer( AccountName from, AccountName to, uint64_t amount )
This message handler is called anytime the @tok currency contract transfers TOK to or from the @storage contract. When tokens are received the producers will reserve space for the user based upon the current price of storage. When tokens are transferred away it will be rejected if it would reduce the user’s reserved space below the used space.
setlink( AccountName owner, string eosiopath, string ipfspath, uint32 size, bool store )
So long as eosiopath is unique and doesn’t start with a prefix of an existing eosiopath and the ipfspath is a valid IPFS path, then the link is created. If eosiopath already exists then it is updated to the new ipfspath. If the storage flag is set then block producers will attempt to cache the file.
This requires the authority and scope of the owner.
removelink( AccountName owner, string eosiopath )
The eosiopath must exist. After removing a path the user’s quota usage is reduced by the indicated file size.
This requires the authority and scope of the owner.
acceptstore( AccountName producer, AccountName owner, string eosiopath )
Any active block producer can call this method to claim they have successfully stored the file referenced by the ipfspath linked to by the eosiopath. At this time the used space
This requires the authority of the producer and the scope of the owner.
rejectstore( AccountName producer, AccountName owner, string eosiopath )
The eosiopath must exist. Any producer can use this to indicate that they have rejected the request to store a particular file. This may be called at any time and is intended for cases where a producer would be exposed to legal or criminal liability for continuing to store the file.
This requires the authority of the producer and the scope of the producer. It has no side effects or behaviors other than to notify the community that a particular producer has declined to store a file. This creates a database of files that may be suspicious and serves as an advisory for everyone. A block producer that does not publish a reject message is bound by contract to store and serve the file at eosiopath.
This requires the authority and scope of the producer.
Waiting on https://github.com/EOSIO/eos/pull/274 to be merged.
Here is my understanding of this assignment. Please correct me if I am wrong:
-
transfer: Similar to currency contract implementation except we don't remove account if balance = 0.
-
setlink: This will do following: a. Check the authorization of owner. b. Verify that it is a valid ipfs path. How do we do this without installing ipfs? c. Verify the validity of eosiopath (is it in right format). d. Verify that eosiopath is unique e. Verify that eosiopath does not start with a prefix of an existing eosiopath. This means that if eosiopath is /tmp/test and there is already a /tmp path we reject. f. Store the entire info (eosiopath, ipfspath, size, store) under account scope into db.
-
removelink: This will do following: a. Check the authorization of owner. b. Check that file belongs to owner. c. Delete the link in database. d. Reduce quota usage (by how much? - 1 TOK = ? bytes) e. How do we inform producer to remove cached file?
-
acceptstore: a. This is done by the producer; checks the authorization of producer and will notify whom?. b. Charge account for storage. what if store flag in setlink is false? c. Store anything or update database?
-
rejectstore: a. Done by producer; checks authorization of producer and will notify whom? b. Store in a new table rejected links.
@bytemaster Dan can you please review Pravin's list and comment on his understanding of the Storage API.
Thank you
How would you prevent the price being 0 when the balance is 0 (ie. first message)
The storage whitepaper refers to Balance being the amount of space consumed, is this the same as the amount of space reserved?
price is never 0 because price is based upon the post reseveration amount rather than the pre-reservation amount.
The String Key/value database has been merged.
- transfer should remove if empty
- verification of IPFS paths is just verifying character subset and approximate length ranges
- accept store is only valid if store flag is set to true, no one is notified, database is updated to increase used quota and indicate the file has been accepted by both
- rejected links are just a flag on existing links, not a new table
See pull request https://github.com/EOSIO/eos/pull/494 for base implementation without functionality.
Blocked on https://github.com/EOSIO/eos/issues/493 and https://github.com/EOSIO/eos/issues/492
Waiting for design approval.
Design document reviewed and feedback was provided. Most of the questions were clarified except a few.
- Implemented ABI
- Requested for clarifications on the document
This was written in light of the currency design that was multiple versions ago.