看啥推荐读物
专栏名称: 星想法
从技术人的角度,理解技术,理解世界,理解金融经济,记录分享生活工作的点滴。
今天看啥  ›  专栏  ›  星想法

星云链源代码 - 基本数据结构

星想法  · 公众号  ·  · 2018-07-31 20:46
在介绍Block区块之前,先介绍区块使用的一些通用的数据结构。1) 存储 StorageNebulas定义了存储(Storage)的接口,并实现了三种存储类型:RocksStorage,MemoryStorage, DiskStorage。相关的源代码在storage 目录下。1.  // Storage interface of Storage.  2.  type Storage interface {  3.      // Get return the value to the key in Storage.  4.      Get(key []byte) ([]byte, error)  //读5.    6.      // Put put the key-value entry to Storage.  7.      Put(key []byte, value []byte) error  //写8.    9.      // Del delete the key entry in Storage.  10.    Del(key []byte) error  //删除11.  12.    // EnableBatch enable batch write.  13.    EnableBatch()  //开启Batch模式14.  15.    // DisableBatch disable batch write. ………………………………

原文地址:访问原文地址
快照地址: 访问文章快照