kadena-io / juno

Smart Contracts Running on a BFT Hardened Raft
BSD 3-Clause "New" or "Revised" License
453 stars 53 forks source link

implement persistence? #24

Open lichengqian opened 8 years ago

lichengqian commented 8 years ago

hello everyone : i have spent a lot of time to read juno code and run the test in my computer i am trying to implement persistence feature myself, and this is my idea and plan:

       1.   change Seq LogEntry  to   Seq (LogIndex, LogEntry),  all unapplyed command stay in memory, and all applied command save to database.

       2.  declare PLogEntry , means persisntent LogEntry:
-- 只保存已经确认并已apply的LogEntry
share [mkPersist sqlSettings, mkMigrate "migrateBlockchain"] [persistLowerCase|
PLogEntry
    index Int
    term Int
    clientId ByteString
    requestId ByteString
    commandEntry ByteString
    commandSig   ByteString
    quorum_votes  ByteString
    sig           ByteString
    hash    ByteString
    commandResult ByteString
    deriving Show
|]
  3.  when server start , i need to load latest logentry to memory(LastAppliedIndex, LastCommitIndex...)

  4.  when a command is confirmed and applied, i need to write it to the database

  of course it need modify a lot of code ,  

  is this idea works? or any better idea?

 by the way , can i join the dev team and do some develop work? and how?
axman6 commented 8 years ago

You need to fill in the functions that are used in the RaftSpec datatype, see https://github.com/buckie/juno/blob/96bac6174ccfa29be329810cc2f73b5eedb799ea/src/Juno/Types/Spec.hs