當前位置: 首頁>>代碼示例>>Golang>>正文


Golang factoid.IHash類代碼示例

本文整理匯總了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)

}
開發者ID:conseweb,項目名稱:factoid,代碼行數:33,代碼來源:factoidstate.go

示例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)
}
開發者ID:conseweb,項目名稱:factoid,代碼行數:37,代碼來源:factoidstate.go

示例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)
}
開發者ID:conseweb,項目名稱:factoid,代碼行數:5,代碼來源:boltdb.go

示例4: Get

func (db *BoltDB) Get(bucket string, key fct.IHash) (value fct.IBlock) {
	return db.GetRaw([]byte(bucket), key.Bytes())
}
開發者ID:conseweb,項目名稱:factoid,代碼行數:3,代碼來源:boltdb.go

示例5: cp

func cp(a fct.IHash) [fct.ADDRESS_LENGTH]byte {
	r := new([fct.ADDRESS_LENGTH]byte)
	copy(r[:], a.Bytes())
	return *r
}
開發者ID:conseweb,項目名稱:factoid,代碼行數:5,代碼來源:boltdb_test.go


注:本文中的github.com/FactomProject/factoid.IHash類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。