TLDR: explicit links use link_entries(base, target...)
to explicitely define relationships, while with implicit links one entry contains the address of another entry and we don't use any hdk api.
There are two main ways to declare relationships between different entries in Holochain: implicit links and explicit links.
They both share one common thing: they are unidirectional, meaning that we can only declare a link from one base entry to another target entry. If we need to be able to navigate both ways, we have to declare the link in both directions.
Both kinds of linking have their place when designing a holochain app. The basic question you can ask to know if a relationship between entries is better expressed as implicit or explicit links is this:
For example, a tweet entry should change of identity when we change the author of the tweet. But the agent entry should not change when we add a new tweet.
Explicit and implicit links are often used with one another to be able to navigate relationships of entries.
In a twitter example, a tweet would reference the
author_address
(implicit link) to be able to navigate to the author, but we would declare an explicit link from agent addresses to all the tweets that that agent has made.
Explicit links use the built-in linking mechanism of Holochain, allowing to define links of a certain type and semantic tag between two already existing entries, with a base entry and a target entry. These types of links:
links: [
from!(
ANCHOR_TYPE,
link_type: ANCHOR_LINK_TYPE,
validation_package: || {
hdk::ValidationPackageDefinition::Entry
},
validation: |_validation_data: hdk::LinkValidationData| {
Ok(())
}
)
]
#[zome_fn("hc_public")]
fn create_chunk(chunk: String) -> ZomeApiResult<Address> {
let entry = Entry::App("chunk".into(), Chunk::from(chunk).into());
let chunk_address = hdk::commit_entry(&entry)?;
hdk::link_entries(&AGENT_ADDRESS.clone(), &chunk_address, "author->chunk", "")
}
In implicit links, the content of one entry contains the address of another referenced entry.
These links are not explicit in any holochain mechanisms, nonetheless they are very useful for navigating your entry graph.
or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Syncing