blockHeaderPrefix = []byte("BH:")
txStatusPrefix = []byte("BTS:")
cliamTxPreFix = []byte("Claim:")
+ dposPreFix = []byte("dpos:")
)
func loadBlockStoreStateJSON(db dbm.DB) *protocol.BlockStoreState {
return append(cliamTxPreFix, hash.Bytes()...)
}
+func calcDPosKey(hash *bc.Hash) []byte {
+ return append(dposPreFix, hash.Bytes()...)
+}
+
// GetBlock return the block by given hash
func GetBlock(db dbm.DB, hash *bc.Hash) *types.Block {
bytez := db.Get(calcBlockKey(hash))
batch.Set(calcClaimTxKey(hash), []byte("1"))
batch.Write()
}
+
+func (s *Store) Set(hash *bc.Hash, data []byte) error {
+ batch := s.db.NewBatch()
+ batch.Set(calcDPosKey(hash), data)
+ batch.Write()
+ return nil
+}
+
+func (s *Store) Get(hash *bc.Hash) ([]byte, error) {
+ data := s.db.Get(calcDPosKey(hash))
+ if data == nil {
+ return nil, errors.New("can't find the snapshot by given hash")
+ }
+ return data, nil
+}