第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

請問有源碼嗎?

老師,請問有源碼嗎?能分享一下給大家嗎?

正在回答

3 回答

package?core

import?(
???"fmt"
???"log"
)

type?Blockchain?struct?{
???Blocks?[]*Block
}


//創(chuàng)世區(qū)塊鏈
func?NewBlockChain()?*Blockchain?{
???genesis?:=?GenerateOriginBlock()
???blockchain?:=?Blockchain{}
???blockchain.AppendBlock(&genesis)
???return?&blockchain
}

//每一個新數(shù)據(jù)都創(chuàng)建一個區(qū)塊,方便外部調(diào)用
func?(bc?*Blockchain)SendData(data?string)?{
???preBlock?:=?bc.Blocks[len(bc.Blocks)?-?1]
???newBlock?:=?GenerateNewBlock(*preBlock,?data)
???bc.AppendBlock(&newBlock)
}


//往區(qū)塊鏈里添加區(qū)塊
func?(bc?*Blockchain)?AppendBlock(newBlock?*Block)?{
???if?len(bc.Blocks)?==?0?{//第一個區(qū)塊
??????bc.Blocks?=?append(bc.Blocks,newBlock)
??????return
???}
???if?!isValid(*newBlock,*bc.Blocks[len(bc.Blocks)?-?1])?{
??????log.Fatal("Invalid?block")
???}
???bc.Blocks?=?append(bc.Blocks,newBlock)
}

//打印區(qū)塊鏈
func?(bc?*Blockchain)?Print()??{
???for?_,block?:=?range?bc.Blocks?{
??????fmt.Printf("Index:%d\n",block.Index)
??????fmt.Printf("PrevHash:%s\n",block.PrevBlockHash)
??????fmt.Printf("Hash:%s\n",block.Hash)
??????fmt.Printf("Timestamp:%d\n",block.Timestamp)
??????fmt.Printf("Data:%s\n",block.Data)
???}
}
//新區(qū)塊校驗
func?isValid(newBlock?Block,oldBlock?Block)?bool?{
???if?newBlock.Index?-?1?!=?oldBlock.Index?{
??????return?false
???}

???if?newBlock.PrevBlockHash?!=?oldBlock.Hash?{
??????return?false
???}

???if?calculateHash(newBlock)?!=?newBlock.Hash?{
??????return?false
???}
???return?true
}


0 回復(fù) 有任何疑惑可以回復(fù)我~
package?core

import?(
???"fmt"
???"log"
)

type?Blockchain?struct?{
???Blocks?[]*Block
}


//創(chuàng)世區(qū)塊鏈
func?NewBlockChain()?*Blockchain?{
???genesis?:=?GenerateOriginBlock()
???blockchain?:=?Blockchain{}
???blockchain.AppendBlock(&genesis)
???return?&blockchain
}

//每一個新數(shù)據(jù)都創(chuàng)建一個區(qū)塊,方便外部調(diào)用
func?(bc?*Blockchain)SendData(data?string)?{
???preBlock?:=?bc.Blocks[len(bc.Blocks)?-?1]
???newBlock?:=?GenerateNewBlock(*preBlock,?data)
???bc.AppendBlock(&newBlock)
}


//往區(qū)塊鏈里添加區(qū)塊
func?(bc?*Blockchain)?AppendBlock(newBlock?*Block)?{
???if?len(bc.Blocks)?==?0?{//第一個區(qū)塊
??????bc.Blocks?=?append(bc.Blocks,newBlock)
??????return
???}
???if?!isValid(*newBlock,*bc.Blocks[len(bc.Blocks)?-?1])?{
??????log.Fatal("Invalid?block")
???}
???bc.Blocks?=?append(bc.Blocks,newBlock)
}

//打印區(qū)塊鏈
func?(bc?*Blockchain)?Print()??{
???for?_,block?:=?range?bc.Blocks?{
??????fmt.Printf("Index:%d\n",block.Index)
??????fmt.Printf("PrevHash:%s\n",block.PrevBlockHash)
??????fmt.Printf("Hash:%s\n",block.Hash)
??????fmt.Printf("Timestamp:%d\n",block.Timestamp)
??????fmt.Printf("Data:%s\n",block.Data)
???}
}
//新區(qū)塊校驗
func?isValid(newBlock?Block,oldBlock?Block)?bool?{
???if?newBlock.Index?-?1?!=?oldBlock.Index?{
??????return?false
???}

???if?newBlock.PrevBlockHash?!=?oldBlock.Hash?{
??????return?false
???}

???if?calculateHash(newBlock)?!=?newBlock.Hash?{
??????return?false
???}
???return?true
}



0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

請問有源碼嗎?

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號