Storage Method

This section describes the data classification, attributes, and storage methods

Data Classification

There are two data categories in CESS: idle and active.

Idle data: Storage nodes use idle data to prove how much storage space they have. Idle data is generated by the TEE Worker of the consensus node in the trusted execution environment, which is unique and verifiable. Storage nodes request idle data from the consensus node and report it to the blockchain network. The blockchain network increases the idle space of storage nodes and calculates rewards for each challenge.

Active data: Active data is user uploaded data and is permanently stored in storage nodes. When a storage node stores an active data, it is necessary to delete a random idle data and replace it with the active data, as the benefits of storing active data is higher than that of idle data. CESS network encourages storage nodes to store more active data.

Data attributes

CESS is an object-based storage service, where all data includes two types of attributes: metadata and data content.

Metadata: It is a description of data content, including data length, data unique identifier, data owner, data location index, etc. The structure of the metadata is defined bellow:

pub struct FileInfo<T: Config> {
	pub(super) completion: BlockNumberOf<T>,
	pub(super) stat: FileState,
	pub(super) segment_list: BoundedVec<SegmentInfo<T>, T::SegmentCount>,
	pub(super) owner: BoundedVec<UserBrief<T>, T::OwnerLimit>,
}

pub struct SegmentInfo<T: Config> {
	pub(super) hash: Hash,
	pub(super) fragment_list: BoundedVec<FragmentInfo<T>, T::FragmentCount>,
}

pub struct FragmentInfo<T: Config> {
	pub(super) hash: Hash,
	pub(super) avail: bool,
	pub(super) miner: AccountOf<T>,
}

pub struct UserBrief<T: Config> {
	pub user: AccountOf<T>,
	pub file_name: BoundedVec<u8, T::NameStrLimit>,
	pub bucket_name:  BoundedVec<u8, T::NameStrLimit>,
}

pub enum FileState {
	Active,
	Calculate,
	Missing,
	Recovery,
}

Data content: is the content stored of the data itself.

Storage method

All metadata will be stored in the blockchain network, and there will also be backups in the cache of the storage node. The data content will eventually be stored in the storage node and stored on the disk in the form of a file. The file name is the hash value of the content, and the hash value is calculated using the SHA-256 hash function.

The following figure shows the file directory structure after the storage node is running. The directory is located in the user specified folder in the configuration file, and has three levels of directory structure. The first level directory is the name of the storage node's signature account, the second level directory is fixed as bucket, and the third level directory includes cache, file, log, space, and temp directories. The space directory stores idle data, while the file directory stores active data.