本文整理匯總了Golang中github.com/FactomProject/FactomCode/common.DirectoryBlock.UnmarshalBinaryData方法的典型用法代碼示例。如果您正苦於以下問題:Golang DirectoryBlock.UnmarshalBinaryData方法的具體用法?Golang DirectoryBlock.UnmarshalBinaryData怎麽用?Golang DirectoryBlock.UnmarshalBinaryData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/FactomProject/FactomCode/common.DirectoryBlock
的用法示例。
在下文中一共展示了DirectoryBlock.UnmarshalBinaryData方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: FetchAllDBlocks
// FetchAllDBlocks gets all of the fbInfo
func (db *LevelDb) FetchAllDBlocks() (dBlocks []common.DirectoryBlock, err error) {
db.dbLock.Lock()
defer db.dbLock.Unlock()
var fromkey []byte = []byte{byte(TBL_DB)} // Table Name (1 bytes) // Timestamp (8 bytes)
var tokey []byte = []byte{byte(TBL_DB + 1)} // Table Name (1 bytes)
dBlockSlice := make([]common.DirectoryBlock, 0, 10)
iter := db.lDb.NewIterator(&util.Range{Start: fromkey, Limit: tokey}, db.ro)
for iter.Next() {
var dBlock common.DirectoryBlock
_, err := dBlock.UnmarshalBinaryData(iter.Value())
if err != nil {
return nil, err
}
//TODO: to be optimized??
dBlock.DBHash = common.Sha(iter.Value())
dBlockSlice = append(dBlockSlice, dBlock)
}
iter.Release()
err = iter.Error()
return dBlockSlice, nil
}