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.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
5: Linking data together
Hash-based content-addressable storage, such as Holochain's DHT, has one big advantage–-you can ignore the physical location of data and ask for it by its fingerprint. This means no broken URLs, unavailable resources, or nasty surprises about what the entry contains.
It does, however, make it hard to find the data you're looking for. If it were all on one machine, you could just do a quick search. But on a distributed system, where everyone has a little bit of the whole data set, that would get pretty slow.
So all we have are hashes. This creates a chicken-and-egg problem. In order to find a piece of data, you need to know its hash. But in order to generate a hash, you need the data.
So how do we find what we're looking for?
Holochain lets you link any two entries together. Each link has a type identifier that indicates the nature of the relationship. This lets you connect known things to unknown things, which then become known things, and so on. Your app's DHT becomes a graph database.
A link is stored in the DHT as metadata along with the entry it links from. So all you need in order to get the links on an entry is its hash.
What sort of 'known things' are there in a DHT that we can use as a starting point?
Here's an example using a fictional indie music sharing app.
Alice is a singer-songwriter who excels at the ukulele. She wants to share her songs with the world.
Alice joins the app and wants to register the username
@alice_ukulele
. She checks whether it's already been taken by looking for an existingusername
entry on the DHT.That username is available, so she creates a
username
entry containing her username and links it to her agent ID entry.Alice wants to show up in the public directory of artists, so she links her username entry to an
_all_users_
anchor. This anchor's value is hard-coded into the app and is used to retrieve the directory.Alice creates a listing for her debut EP album and links it to her agent ID entry. Listeners can now retrieve all the albums she's recorded.
Now she uploads all the tracks and links them to the album.
She wants people to be able to find her album by genre, so she selects three applicable genres and links her album to them.
Those genres are already linked to an
_all_genres_
anchor, whose value is hard-coded into the app. Listeners can query this anchor for links and get the full list of genres.Alice's entries, linked to each other and to existing entries on the DHT, now form a graph that allows listeners to discover her and her music from a number of different starting points.
Learn more
Tutorial: SimpleMicroBlog >
Next: Modifying and deleting data >>
tags:
Holochain Core Concepts