Storing data directly on the blockchain can be costly due to the increased computational resources, storage space, and transaction fees required. One solution to this problem is the use of IPFS (InterPlanetary File System) for decentralized data storage and retrieval. IPFS utilizes a content-addressable storage system, where files are identified by their content rather than their location. Each file is assigned a unique cryptographic hash, called a content address, which serves as its identifier.
IPFS breaks large files into smaller pieces called blocks, which are then distributed across multiple nodes in the network. This creates a distributed file system that allows for peer-to-peer storage and retrieval of files, without relying on a single server or centralized database. Unlike HTTP, which uses domain names and IP addresses to identify the location of a resource, IPFS uses content-addressable storage.
DAG (Directed Acyclic Graph) is used as a content storage mechanism to organize and store files on the IPFS network. DAGs are a type of data structure that can be used to represent complex relationships between objects, and they are particularly useful in distributed systems like IPFS.
The DAG structure allows IPFS to efficiently store and retrieve large files by breaking them down into smaller blocks, and it enables the network to be more scalable, resilient, and secure. The content-addressability of IPFS is enabled by the DAG structure, where each node of the DAG represents a CID (Content Identifier), which is a hash of that block of data.
DHT (Distributed Hash Table) is a distributed mechanism to discover content on the IPFS network. It allows nodes to find the location of files stored on the network and retrieve them efficiently, even if some nodes are not available. DHTs are resilient and fault-tolerant, ensuring that the network is always able to find and retrieve files.
Provider records, IPNS records, and Peer ID records are all key-value pairings in the DHT that are used to track and support various network features.
Overall, IPFS is a powerful solution for decentralized data storage and retrieval, offering a more efficient, resilient, and secure alternative to traditional centralized storage methods. It is particularly useful for applications that require large files and require a high degree of security.