IPFSDictChain Module

class ipfs_dict_chain.IPFSDictChain.IPFSDictChain(cid: str | None = None)[source]

Bases: IPFSDict

A dictionary-like data structure that stores its state on IPFS and keeps track of changes.

Parameters:

cid (Optional[str], optional) – The IPFS CID to initialize the dictionary with, defaults to None

changes() Dict[str, Dict[str, Any]][source]

Returns a dictionary containing the changes between the current state and the previous state.

Returns:

A dictionary of changes, with keys as attribute names and values as dictionaries containing the old and new values

Return type:

Dict[str, Dict[str, Any]]

get_previous_cids(max_depth: int | None = None) List[str][source]

Returns a list of previous CIDs.

Parameters:

max_depth (Optional[int], optional) – The maximum number of previous CIDs to return, defaults to None

Returns:

A list of previous CIDs

Return type:

List[str]

get_previous_states(max_depth: int | None = None) List[Dict[str, Any]][source]

Returns a list of previous states as dictionaries.

Parameters:

max_depth (Optional[int], optional) – The maximum number of previous states to return, defaults to None

Returns:

A list of previous state dictionaries

Return type:

List[Dict[str, Any]]

save() str[source]

Saves the current state of the dictionary to IPFS and returns the new CID.

Returns:

The new IPFS CID

Return type:

str