haydnv / tinychain

A next-gen database + SaaS framework for rapid development and integration of enterprise services

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`BlockChain` should have a single `impl<T> Replica for BlockChain<T>`

haydnv opened this issue · comments

currently there are separate impls for CollectionBase and each type of Cluster

Prerequisites:

  • impl FromStream and IntoStream for File and Dir

Steps:

  1. update chain history so that the "previous hash" of the first block is the hash of the initial state of the subject of the chain
  2. update BlockChain::create and BlockChain::load to accept an initial state rather than the schema of an initial state
  3. store the initial state of the chain subject separately in the chain history
  4. update BlockChain::into_view so that it returns the Dir containing the initial state of the subject (not the subject itself) and update BlockChain::from_stream to validate that the initial hash is the hash of the initial state of the subject, then apply the mutations in the chain to the initial state of the subject in order to build the current state of the subject
  5. impl<T: Persist + Public> Replica for Chain<T>