mix irving
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    <!-- Generic ?? --> # Tangles A "tangle" in scuttlebutt is a way to define a directed acyclic graph (DAG) of messages. They are a useful way to determine a partial ordering which is useful for everything from replication to building multi-writer "records". There are different types of tangle, but they all must specify: 1. **candidate messages**: the set of messages which _could_ be part of the tangle 2. **a recipe**: how the tangle (DAG) is constructed from these candidates It is common for the recipe to start with some "root message" and extend out from that point, checking the validity of messages as they are added. Some candidate messages may not have connections to the graph, or may be "invalid" extentions, in which case they are excluded from the tangle. ## Classic feed tangle The most trivial tangle is the classic scuttelbutt feed. In this case, the tangle for feed `A` is defined as: 1. **candidate messages**: - have `msg.value.author == A` - have `msg.value.signature` which is the signature of `msg.value.content` by `A` 2. **recipe**: - find the message with `msg.value.sequence == 1` as your "root" - check it's signed correctly `A` - find the message with `msg.value.sequence == 2` - check it's signed correctly by `A` - check `msg.value.previous` points to the previous message - if all that's fine, add this message to the chain - repeat (incrementing the sequence) ```mermaid flowchart RL subgraph "feed" direction RL d-->c-->b-->a end classDef default stroke:#ccc,fill:#eee; classDef cluster stroke:#333,fill:none; ``` The tangle data these messages carry looks like: ```javascript a => { sequence: 1, previous: null } b => { sequence: 2, previous: a } c => { sequence: 3, previous: b } d => { sequence: 3, previous: d } ``` (author, signature, and content have been ommited here to make the backlinking pattern clearer) ## Multi author tangle In the case of multiple authors, you need to be able to support a DAG which branches and merges (because different authors may contribute concurrently, or while offline). ```mermaid flowchart RL M-->X-->B-->A M-->Y--->B classDef default stroke:none; classDef alice fill:#ccf; classDef bob fill:#cfc; class A,X,M alice class B,Y bob ``` _Diagram where messages X, Y were both published concurrently (so were unaware of one another). M is aware of both X and Y, and extends the tangle from them. M is now the new "tip" of the tangle._ The tangle data these messages carry looks like: ```javascript A => { root: null, previous: null } B => { root: A, previous: [A] } X => { root: A, previous: [B] } Y => { root: A, previous: [B] } M => { root: A, previous: [X, Y] } ``` Where: - `root` is the id of the root message of the the tangle - `previous` is an Array of message ids of the tip(s) / leading edges of the tangle at the time this message was published. Note: the root message cannot include its own id (not known until published), so it sets it's `root` value as `null`, which means "I am a root" <!-- Specificic to private groups --> ### Members tangle The purpose of this tangle is to track the group membership (for a particular epoch of the group). We define the members tangle for some id `A` as: 1. **candate messages**: - the root message with id `A` so long as it has ```javascript content.tangles.members = { root: null, previous: null } ``` - any messages where ```javascript content.tangles.members = { root: A, previous: [...] } ``` 2. **recipe**: - a) the graph starts with the root message - b) for the current tip(s) of the tangle - find candidate messages which list that tip in the `previous` field of their tangle data - check that the graph contains each message in `previous` - if it does, add it to the graph - otherwise set it aside till the graph does contain them - newly added messages to the tangle graph constitue new tips - c) repeat (b) till you cannot grow the tangle further In the context of private groups, the addition to a particular epoch is always published to an earlier epoch (or in the case of the first epoch, to the Additons feed). ```mermaid flowchart RL subgraph Additions 0_add_0[add: Alice] 0_add_1[add: Bob, Carol] end subgraph epoch_0[Epoch 0] 0_init[init] end %% members tangle - epoch 0 0_add_1 --> 0_add_0 --> 0_init linkStyle 0,1 stroke:#118AB2,stroke-width:3; classDef default stroke:#ccc,fill:#eee; classDef cluster fill:#fff,stroke:#000,color:#333; ``` ### Epoch tangle The purpose of the epoch tangle is to track progression of epochs that constitutes each group. For some group id `G`, where `A` is the id of the initial `group/init` message (in epoch 0), then define the epoch tangle for `G` as: 1. **candate messages**: - the root message with id `A` so long as it has ```javascript content.type = 'group/init' content.tangles.epoch = { root: null, previous: null } ``` - any messages where ```javascript content.type = 'group/init' content.tangles.epoch = { root: A, previous: [...] } ``` 2. **recipe**: - a) the graph starts with the root message - b) for the current tip(s) of the tangle - find candidate messages which list that tip in the `previous` field of their tangle data - check that the graph contains each message in `previous` - if it does, add it to the graph - otherwise set it aside till the graph does contain them - newly added messages to the tangle graph constitue new tips - c) repeat (b) till you cannot grow the tangle further ```mermaid flowchart RL subgraph epoch_0[Epoch 0] 0_init[init] end subgraph epoch_1[Epoch 1] 1_init[init] end %% epoch tangle 1_init --> 0_init linkStyle 0 stroke:#EF476F,stroke-width:2; classDef default stroke:#ccc,fill:#eee; classDef cluster fill:#fff,stroke:#000,color:#333; ``` ### Group tangle The purpose of the group tangle is to clearly identify all messages which are part of a particular group, and provide partial causal ordering. For some group id `G`, where `A` is the id of the initial `group/init` message (in epoch 0), then define the group tangle for `G` as: 1. **candate messages**: - the root message with id `A` so long as it has ```javascript content.type = 'group/init' content.tangles.group = { root: null, previous: null } ``` - any messages where ```javascript content.tangles.group = { root: A, previous: [...] } ``` 2. **recipe**: - a) the graph starts with the root message - b) for the current tip(s) of the tangle - find candidate messages which list that tip in the `previous` field of their tangle data - check that the graph contains each message in `previous` - if it does, add it to the graph - otherwise set it aside till the graph does contain them - newly added messages to the tangle graph constitue new tips - c) repeat (b) till you cannot grow the tangle further <!-- ```mermaid flowchart RL M -.-> X & Y -.-> B -.-> A linkStyle 0,1,2,3,4 stroke:#FFD166,stroke-width:4; classDef default stroke:none,fill:#ccf; classDef cluster fill:#fff,stroke:#000,color:#333; ```` --> ### Using all the tangles together ```mermaid flowchart RL subgraph Additions 0_add_0[add: A] 0_add_1[add: B, C] end subgraph epoch_0[Epoch 0] 0_init[init] 1_add_0[add: A, B] 0_remove_2[exclude: C] end subgraph epoch_1[Epoch 1] 1_init[init] end %% epoch tangle 1_init --> 0_init linkStyle 0 stroke:#EF476F,stroke-width:2; %% members tangle - epoch 0 0_remove_2 --> 0_add_1 --> 0_add_0 --> 0_init linkStyle 1,2,3 stroke:#118AB2,stroke-width:3; %% members tangle - epoch 1 1_add_0 --> 1_init linkStyle 4 stroke:#06D6A0,stroke-width:3; %% group tangle 1_add_0 -.- 1_init -.- 0_remove_2 -.- 0_add_1 -.- 0_add_0 -.- 0_init linkStyle 5,6,7,8,9 stroke:#FFD166,stroke-width:4; classDef default stroke:#ccc,fill:#eee; classDef cluster fill:#fff,stroke:#000,color:#333; ``` ```mermaid flowchart LR subgraph key direction RL members_0[members tangle 0] -->A[ ] members_1[members tangle 1] -->B[ ] epoch[epoch tangle] -->C[ ] group[group tangle] -.->D[ ] end linkStyle 0 stroke:#118AB2,stroke-width:3; linkStyle 1 stroke:#06D6A0,stroke-width:3; linkStyle 2 stroke:#EF476F,stroke-width:2; linkStyle 3 stroke:#FFD166,stroke-width:4; classDef default fill:#fff,stroke:none,color:#222; classDef cluster fill:#fff,stroke:#000,color:#333; ``` _NOTE: this diagram shows all nice linear tangles for visual simplicity, remember there may be forks and merges because of concurrent publishing._ Crucially, the `group/init` messages are involved in 3 tangles, e.g. ```javascript { type: `group/init`, // ... tangles: { group: { root: A, previous: [W, X] }, epoch: { root: A, previous: [B] }, members: { root: null, previous: null } } } ``` This message says 1. I am part of a group which started with message `A`, and the last messages I saw in the group were `W, X` 2. The root epoch was `A` and the epoch(s) before this one was `B` 3. I am the root of a new members tangle for this epoch

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    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.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully