1. 16 Mar, 2019 3 commits
    • Eric Myhre's avatar
      Repose refactored into several packages. · 57832ad7
      Eric Myhre authored
      All of which now explicitly confess their cid-specificness.
      
      Some things in the 'repose' draft were *really* twisted; I'm glad that
      first draft is getting replaced before anything actually used it...
      
      For example, NodeBuilderChooser was just ridiculously misplaced abstraction.
      When doing a traversal, you have the local type information (if any) already
      in hand, and can just... pick an appropriate NodeBuilder already.  Now that
      the NodeBuilder is simply a parameter to Link.Load, everything shakes out
      much, much more clearly as a result.
      
      The cidlink package contains all concrete referns to Cids.  This implements
      the ipld.Link and ipld.LinkBuilder interfaces... but if you don't import
      the cidlink package in your program, you won't find any of the cid packages
      (nor their numerous transitive dependencies) in your dependency set.
      
      Multicodecs are now a registry which is confined in scope to the cidlink
      package.  (It's global, but I think in practice this will be fine: it's a
      plugin system, and there's no good cause for allowing variations in how
      those magic bytes of cids are interpreted.)
      
      There are now dagcbor and dagjson packages for encoding.  These explicitly
      refer to the cidlink package (and register themselves on package init).
      While these refer to cidlink, you could imagine we might also introduce
      other encoding packages which *don't*.
      
      Finally, note that the dagcbor and dagjson packages are in fact still not
      done.  This is the same logic/completeness they had before this diff...
      which does not include actual parsing of cids!  However, it's now clear
      where to introduce that and at what scope.  (It will probably require
      more duplication of unmarshalling code than desirable, but, alas, that
      might simply be the cost of doing business.  Dagjson in particular has
      topologically "interesting" things to handle that I'd be loathe to make
      a sufficiently pluggable unmarshal traversal to support; it would be
      possible, but likely a noticable slowdown to continuously check and
      then promptly disregard the interesting case.)
      
      Some work remains, but this is now pretty close to sanity.
      Signed-off-by: default avatarEric Myhre <hash@exultant.us>
      57832ad7
    • Eric Myhre's avatar
      Add context params to link load and build. · dbf02a67
      Eric Myhre authored
      These belong in load and build since those are at the top of the stack;
      they also (perhaps surprisingly) aren't necessary as params to the
      Loader and Storer function interfaces (since those just return readers
      and writers, and thus 'cancel' for those is 'stop using it').
      Signed-off-by: default avatarEric Myhre <hash@exultant.us>
      dbf02a67
    • Eric Myhre's avatar
      Begin introduction of new linking interfaces. · 6950c5cf
      Eric Myhre authored
      This is going to be the start of a pretty hectic set of commits.
      
      1. The LinkLoader, LinkBuilder, and LinkContext types currently in
        the traversal package are hereby doomed (and will be deleted by
        the time this branch is ready to land).
      
      2. Cid itself will disappear from almost all remaining concrete uses.
        For example, traversal.TraversalProgress.LastBlock will use Link
        instead of Cid.  (You'll have to cast back to Cid if that detail
        is important to your application!)
      
      3. The 'repose' package is pretty much getting nuked.
      
      Instead: we have these new interfaces.  Link will be abstract.
      
      We'll add a linking package with a subpackage containing implementation
      with Cids.  Our encoding systems will then also live there: this makes
      sense since multicodec is definitely a detail associated with Cids.
      We'll also have dag-cbor and dag-json specific encodings in subpackages
      associated with this whole thing: those will be able to read and reify
      Link instances during their handling of serial data.  This too is
      parsimonious and correct (e.g. dag-json parsing is technically distinct
      from regular json parsing, even if it's experientially close).
      
      And if all goes according to plan, we will -- shockingly -- be able to
      use almost the entirety of the IPLD system... *without* forming an
      explicit import dependency on the Cid packages *until* we directly use
      any link loading features based on Cids.  That'll be neat.
      
      All these changes will be staged across a series of commits because
      the total diff will definitely be something fierce.
      Signed-off-by: default avatarEric Myhre <hash@exultant.us>
      6950c5cf