本文整理匯總了Golang中github.com/FactomProject/factoid.IHash類的典型用法代碼示例。如果您正苦於以下問題:Golang IHash類的具體用法?Golang IHash怎麽用?Golang IHash使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了IHash類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ProcessEndOfBlock2
// End of Block means packing the current block away, and setting
// up the next block.
// this function is to replace the existing function: ProcessEndOfBlock
func (fs *FactoidState) ProcessEndOfBlock2(nextBlkHeight uint32) {
var hash, hash2 fct.IHash
if fs.currentBlock != nil { // If no blocks, the current block is nil
hash = fs.currentBlock.GetHash()
hash2 = fs.currentBlock.GetLedgerKeyMR()
}
fs.currentBlock = block.NewFBlock(fs.GetFactoshisPerEC(), nextBlkHeight)
t := block.GetCoinbase(fs.GetTimeMilli())
err := fs.currentBlock.AddCoinbase(t)
if err != nil {
panic(err.Error())
}
fs.UpdateTransaction(t)
if hash != nil {
fs.currentBlock.SetPrevKeyMR(hash.Bytes())
fs.currentBlock.SetPrevLedgerKeyMR(hash2.Bytes())
}
cp.CP.AddUpdate(
"blockheight", // tag
"status", // Category
fmt.Sprintf("Directory Block Height: %d", nextBlkHeight), // Title
"", // Msg
0)
}
示例2: ProcessEndOfBlock
// End of Block means packing the current block away, and setting
// up the next block.
func (fs *FactoidState) ProcessEndOfBlock() {
var hash, hash2 fct.IHash
if fs.GetCurrentBlock() == nil {
panic("Invalid state on initialization")
}
hash = fs.currentBlock.GetHash()
hash2 = fs.currentBlock.GetLedgerKeyMR()
fs.PutTransactionBlock(hash, fs.currentBlock)
fs.PutTransactionBlock(fct.FACTOID_CHAINID_HASH, fs.currentBlock)
fs.dbheight += 1
fs.currentBlock = block.NewFBlock(fs.GetFactoshisPerEC(), fs.dbheight)
t := block.GetCoinbase(fs.GetTimeMilli())
err := fs.currentBlock.AddCoinbase(t)
if err != nil {
panic(err.Error())
}
fs.UpdateTransaction(t)
if hash != nil {
fs.currentBlock.SetPrevKeyMR(hash.Bytes())
fs.currentBlock.SetPrevLedgerKeyMR(hash2.Bytes())
}
cp.CP.AddUpdate(
"blockheight", // tag
"status", // Category
fmt.Sprintf("Directory Block Height: %d", fs.GetDBHeight()), // Title
"", // Msg
0)
}
示例3: Put
func (db *BoltDB) Put(bucket string, key fct.IHash, value fct.IBlock) {
b := []byte(bucket)
k := key.Bytes()
db.PutRaw(b, k, value)
}
示例4: Get
func (db *BoltDB) Get(bucket string, key fct.IHash) (value fct.IBlock) {
return db.GetRaw([]byte(bucket), key.Bytes())
}
示例5: cp
func cp(a fct.IHash) [fct.ADDRESS_LENGTH]byte {
r := new([fct.ADDRESS_LENGTH]byte)
copy(r[:], a.Bytes())
return *r
}