Skip to content

Instantly share code, notes, and snippets.

@hackergrrl
Created March 23, 2020 21:10
Show Gist options
  • Save hackergrrl/765a47ccbed6c88b3b0313ea81fe633e to your computer and use it in GitHub Desktop.
Save hackergrrl/765a47ccbed6c88b3b0313ea81fe633e to your computer and use it in GitHub Desktop.

mapeo sync

current mechanism

PEER                                                          PEER
 ||                                                            ||
 ||------- handshake offer ----->                              ||
 ||                                                            ||
 ||                                 <----- handshake offer ----||
 ||                                                            ||
 ||                                                            ||
 ||                                                            ||
 ||------- handshake accept ----->                             ||
 ||                                                            ||
 ||                                <----- handshake accept ----||
 ||                                                            ||
 ||                                                            ||
 ||                                                            ||
 ||------- open multiplexed stream ----->                      ||
 ||                                                            ||
 ||                         <----- open multiplexed stream ----||
 ||                                                            ||
 ||                                                            ||
 ||--MULTIFEED-/-HYPERCORE--||     ||--------BLOB-SYNC---------||
 ||                         ||     ||                          ||
 ||---HAVES-->              ||     ||---HAVES-->               ||
 ||                         ||     ||                          ||
 ||              <--HAVES---||     ||               <--HAVES---||
 ||                         ||     ||                          ||
 ||---WANTS-->              ||     ||---WANTS-->               ||
 ||                         ||     ||                          ||
 ||              <--WANTS---||     ||               <--WANTS---||
 ||                         ||     ||                          ||
 ||---DATA-->               ||     ||---DATA-->                ||
 ||                         ||     ||                          ||
 ||               <--DATA---||     ||                <--DATA---||
 ||                         ||     ||                          ||
 ||           ....          ||     ||          .....           ||
 ||                         ||     ||                          ||
 ||---DATA-->               ||     ||---DATA-->                ||
 ||                         ||     ||                          ||
 ||               <--DATA---||     ||                <--DATA---||
 ||                         ||     ||                          ||
 ||-----------FIN-----------||     ||-----------FIN------------||
 ||                                                            ||
 ||----------------------------FIN-----------------------------||

future mechanism

PEER                                                          PEER
 ||                                                            ||
 ||------- handshake offer ----->                              ||
 ||                                                            ||
 ||                                 <----- handshake offer ----||
 ||                                                            ||
 ||                                                            ||
 ||                                                            ||
 ||------- handshake accept ----->                             ||
 ||                                                            ||
 ||                                <----- handshake accept ----||
 ||                                                            ||
 ||                                                            ||
 ||                                                            ||
 ||------- open multiplexed stream ----->                      ||
 ||                                                            ||
 ||                         <----- open multiplexed stream ----||
 ||                                                            ||
 ||                                                            ||
 ||----------------------------RPC-----------------------------||
 ||                                                            ||
 ||---QUERY-BLOBS-->                                           ||
 ||                                                            ||
 ||                                            <--BLOB-HAVES---||
 ||                                                            ||
 ||                            ...                             ||
 ||                                                            ||
 ||                                            <--QUERY-BLOB---||
 ||---BLOBS-HAVES-->                                           ||
 ||                                                            ||
 ||                            ...                             ||
 ||                                                            ||
 ||---OPEN-MULTIFEED-STREAM-->                                 ||
 ||                                                            ||
 ||                                                <--ACCEPT---||
 ||                                                            ||
 ||           (both sides open an additional stream            ||
 ||                in addition to RPC stream)                  ||
 ||                                                            ||
 ||                                                            ||
 ||--MULTIFEED-/-HYPERCORE--||     ||-----------RPC------------||
 ||                         ||     ||                          ||     <-- regular RPC channel continues to function
 ||---HAVES-->              ||     ||---QUERY-BLOBS-->         ||
 ||                         ||     ||                          ||
 ||              <--HAVES---||     ||          <--BLOB-HAVES---||
 ||                         ||     ||                          ||
 ||                         ||     ||           ...            ||
 ||---WANTS-->              ||     ||                          ||
 ||                         ||     ||---GET-BLOB-->            ||
 ||              <--WANTS---||     ||                          ||
 ||                         ||     ||                <--DATA---||
 ||---DATA-->               ||     ||                          ||
 ||                         ||     ||           ...            ||
 ||               <--DATA---||     ||                          ||
 ||                         ||     ||---QUERY-BLOBS-->         ||
 ||           ....          ||     ||                          ||
 ||                         ||     ||          <--BLOB-HAVES---||
 ||---DATA-->               ||     ||                          ||
 ||                         ||     ||           ...            ||
 ||               <--DATA---||     ||                          ||
 ||                         ||     ||            <--GET-BLOB---||
 ||-----------FIN-----------||     ||                          ||
                                   ||---DATA-->                ||
                                   ||                          ||
                                   ||           ...            ||
                                   ||                          ||
                                   ||-----STREAM KEPT OPEN-----||
                                   
                                   ^^^^ as many RPCs as the  ^^^^
                                   ^^^^ peer wants, in both  ^^^^
                                   ^^^^     directions       ^^^^
                                   ^^^^ (no auto stream end) ^^^^
                                   ^^^^ (could open other    ^^^^
                                   ^^^^ streams like blob    ^^^^
                                   ^^^^ sync or another hyp- ^^^^
                                   ^^^^ -ercore sync         ^^^^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment