# ¶ Some Concepts in PPIO

## ¶ Overview

PPIO is a decentralized programmable storage and delivery network.

PPIO is intentionally built with a minimal feature set that focuses on simplicity. Following are some of the advantages of PPIO:

• Create/Delete Buckets - Create and delete a bucket. Buckets are the fundamental container in PPIO for data storage. Every user could create not more than 100 buckets.
• Store/Delete Objects - Store an infinite amount of data in a bucket. Upload as many objects as you like into a bucket. Each object can contain up to 10 GB of data (8 TB in future). Each object is stored and retrieved using a unique developer-assigned key.
• Renew Objects - Renew your storage plan. You can renew the object's copies and chiprice(See Chiprice), or extend storage time.

• Tasks - Most time-consuming operations in PPIO are asynchronous. Asynchronous operation will generate a task. The developer can manage these tasks by specific APIs. See Task.
• Indexdata - Management of indexdata. See Indexdata.

## ¶ Chiprice

• The concept of chiprice is very similar to the gasprice in Ethereum. And the units of all prices in the following documents are wei. wei is a basic unit of PPIO coin. The conversion relationship between wei and ppcoin is as follows:
1 PPcoin = 1018wei = 1015Kwei = 1012Mwei = 109Gwei = 106Twei = 103Pwei

• Each 128KB’s content storage per hour per copy need 1 chi. Each 128KB’s content downloading need 10 chi.

• Chiprice is user-defined, but it's best not to be less than 100 wei, otherwise there may be no miners willing to work.

## ¶ User Credentials

PPIO's user credentials are generated by the PPIO wallet. You can get more information here

## ¶ Concepts

### ¶ Bucket

A bucket is the primary container for storing objects. An object must be stored in a bucket. The developer could organize namespaces with buckets and use a bucket like an unlimited capacity folder that can contain any number of objects.

### ¶ Object

Objects are the fundamental entities stored in PPIO. Objects consist of object data and indexdata. The data is encrypted and fragmented, it's opaque to PPIO. An object is identified by the key. An object is uniquely identified within a bucket by a key (name).

#### ¶ Object State

State State Code Description
Bid 0 all copies are not available
Part-Deal 1 at least one copy is available, but not all copies are available
Deal 2 all copies are available
Pending-End 3 nearly expires, wait for settlement
End 4 expired

### ¶ Indexdata

PPIO is a decentralized data storage and delivery platform. PPIO uses unique data partition and encryption algorithms, which ensures that user data can only be indexed and retrieved by a unique private key. Moreover, there must be a data structure to maintain the mapping of an object to fragmentation data, which called indexdata. The metadata of the object included in indexdata two.

Most time-consuming operations in PPIO are asynchronous. Asynchronous operation will generate a task, the developer can check the operation with a task.

There are two types, permanent and temporary. The main difference between them is a lifetime.

permanent task: long lifetime, even after task finished or error. The permanent task will be persisted in the local database. Develop can delete it by API.


Every asynchronous call will return a task id, developer can get task state or progress by specific APIs.

// TaskCommonState chunk state in a task

const (
// Pending initializing
// Running
Running
// Paused stopped
Paused
// Finished done
Finished
// Error end with error
Error
)

"Pending",
"Running",
"Paused",
"Finished",
"Error",
}


All operations as follow:

permenent ok ok ok ok
temporary NA NA ok NA

Task in Running state cannot be deleted. Please pause it before deleting.

ok: can be listed with list-tasks command。


Developer can get task progress and state by specific APIs. These APIs usually return the struct:

type JobProgress struct {
// put/get/copy/delete/renew/getstatus...
Action string
TotalSubJobs    int
FinishedSubJobs int
TotalBytes    int64
FinishedBytes int64
// Pending/Running/Paused/Finished/Error
JobState string
Err      string
CurrentSubJobProgress *JobProgress
ExResult string
}


Developer could get state by JobState field and get progress by TotalBytes/FinishedBytes fields. Use JobState==Finished (not FinishedBytes==TotalBytes) to check that a task has finished or not.