Module hdk::entry

source · []
Expand description

Working with app and system entries.

Most Holochain applications will define their own app entry types.

App entries are all entries that are not system entries. They are defined in the entry_defs callback and then the application can call CRUD functions with them.

CRUD in Holochain is represented as a graph/tree of Elements referencing each other (via Header hashes) representing new states of a shared identity. Because the network is always subject to the possibility of partitions, there is no way to assert an objective truth about the ‘current’ or ‘real’ value that all participants will agree on. This is a key difference between Holochain and blockchains. Where blockchains define a consensus algorithm that brings all participants as close as possible to a single value while Holochain lets each participant discover their own truth.

The practical implication of this is that agents fetch as much information as they can from the network then follow an algorithm to ‘walk’ or ‘reduce’ the revisions and discover ‘current’ for themselves.

In Holochain terms, blockchain consensus is walking all the known ‘updates’ (blocks) that pass validation then walking/reducing down them to disover the ‘chain with the most work’ or similar. For example, to implement a blockchain in Holochain, attach a proof of work to each update and then follow the updates with the most work to the end.

There are many other ways to discover the correct path through updates, for example a friendly game of chess between two players could involve consensual re-orgs or ‘undos’ of moves by countersigning a different update higher up the tree, to branch out a new revision history.

Two agents with the same information may even disagree on the ‘correct’ path through updates and this may be valid for a particular application. For example, an agent could choose to ‘block’ another agent and ignore all their updates.

Traits

Trait for binding static EntryDef property access for a type. See register_entry

Functions

General function that can create any entry type.

Create an app entry. Also see create.

General function that can delete any entry type.

Delete an app entry. Also see delete.

Gets an element for a given entry or header hash.

Get an element and its details for the entry or header hash passed in. Returns None if the entry/header does not exist. The details returned are a contextual mix of elements and header hashes.

MUST get an EntryHashed at a given EntryHash.

MUST get a SignedHeaderHashed at a given HeaderHash.

MUST get a VALID Element at a given HeaderHash.

General function that can update any entry type.

Update an app entry. Also see update.