由于在跟着做实验室的区块链项目,大概是共识锁相关,需要学习区块链相关的开发,自己学习go语言,并实现了一个非常简单的区块链demo。 golang的语法有点意思。 大概是将用户个人信息和会议信息,上一个链节点的hash码等结合并用sha256加密形成一个hash码,用以确认身份/加密。并有相关信息的安全性验证。还有很多功能没有实现,比如工作量证明(PoW),放到web等等。 慢慢来吧。 packagemain;import("fmt""crypto/sha256""encoding/hex""math/rand""time""strconv")typeBlockstruct{block...

  Ld1ydcUEqbSi   2023年11月02日   41   0   0 d33d3c

废话不多说,开始跟我用golang搭建个迷你区块链: 首先,引入包: packagemainimport("bytes""crypto/sha256""encoding/binary""fmt""math""math/big""time") 设置一些常量,工作量证明难度系数dif,搜索上界INT64_MAX: const(dif=20INT64_MAX=math.MaxInt64) 然后我们设计一个简单的区块体和区块链体,每个区块呢有前个区块哈希,本区块哈希,数据,链长,时间戳和随机数: typeBlockstruct{PrevHash[]byteHa...

  Ld1ydcUEqbSi   2023年11月02日   41   0   0 区块链unix

Givenastring,findthelengthofthe longestsubstring withoutrepeatingcharacters. Example1: Input:"abcabcbb"Output:3Explanation:Theansweris​​"abc"​​,withthelengthof3. Example2: Input:"bbbbb"Output:1Explanation:Theansweris​​"b"​​,withthelengthof1. Example3: Input:"pwwkew"Output:3Explanatio...

  Ld1ydcUEqbSi   2023年11月02日   27   0   0 i++
关注 更多

空空如也 ~ ~

粉丝 更多

空空如也 ~ ~