代码拉取完成,页面将自动刷新
package main
import (
"math/big"
"gitee.com/prestonTao/libp2parea/config"
"gitee.com/prestonTao/libp2parea/engine"
"gitee.com/prestonTao/libp2parea/nodeStore"
"gitee.com/prestonTao/utils"
)
/*
搜索逻辑节点id算法
*/
func main() {
example()
}
func example() {
engine.Log.Info("start")
kl := nodeStore.NewKademlia(0)
//要查找的节点ID
findNetid := nodeStore.AddressFromB58String("J4VhVRKxqsuTrqTDreHz8qemMWAT3S5kg9mBdgusuv5p")
// netids := make([]*big.Int, 0)
netid1 := nodeStore.AddressFromB58String("65U2vEhNAq2PNzMT9SCK2d6sZCULSFvD8vvLwRZpJkgx")
kl.Add(new(big.Int).SetBytes(netid1))
// netids = append(netids, new(big.Int).SetBytes(netid1))
netid2 := nodeStore.AddressFromB58String("AfwFmdvpqjXmVpR7MP1vQonLucaf1rQg6v7BJ9W6AirL")
kl.Add(new(big.Int).SetBytes(netid2))
// netids = append(netids, new(big.Int).SetBytes(netid2))
netid3 := nodeStore.AddressFromB58String("6vk8xDbbZaT74eMfvbfby1VCifYF31qKmTpcwFk41aQH")
kl.Add(new(big.Int).SetBytes(netid3))
// netids = append(netids, new(big.Int).SetBytes(netid3))
netid4 := nodeStore.AddressFromB58String("5bzPVbPzp9WMbXkH6w1qaYSD93FGVdbyuHYUNbioZCrU")
kl.Add(new(big.Int).SetBytes(netid4))
// netids = append(netids, new(big.Int).SetBytes(netid4))
netid5 := nodeStore.AddressFromB58String("YYBNvYGxyAxPeLNwjkBrjwuPnaCawwD3nbEPH7vyuZ5")
kl.Add(new(big.Int).SetBytes(netid5))
// netids = append(netids, new(big.Int).SetBytes(netid5))
netid6 := nodeStore.AddressFromB58String("9cV2PRMi9g7g92EQjQG4jU3pA3Rdu1ffxGu3i4KgQ9yX")
kl.Add(new(big.Int).SetBytes(netid6))
// netids = append(netids, new(big.Int).SetBytes(netid6))
// asc := nodeStore.NewIdASC(new(big.Int).SetBytes(findNetid), netids)
// result := asc.Sort()
// for _, idBig := range result {
// netidBs := idBig.Bytes()
// engine.Log.Info("最近的节点:%s", nodeStore.AddressNet(netidBs).B58String())
// }
targetIds := kl.Get(new(big.Int).SetBytes(findNetid))
targetId := targetIds[0]
targetIdBs := targetId.Bytes()
mh := nodeStore.AddressNet(*utils.FullHighPositionZero(&targetIdBs, config.Addr_byte_length))
engine.Log.Info("检查id结果:%s", mh.B58String())
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。