MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / createNodesWithPublicKey

Function createNodesWithPublicKey

xenomint/xxx_test.go:116–152  ·  view source on GitHub ↗
(
	pub *ca.PublicKey, diff int, num int)

Source from the content-addressed store, hash-verified

114}
115
116func createNodesWithPublicKey(
117 pub *ca.PublicKey, diff int, num int) (nis []proto.Node, err error,
118) {
119 var (
120 nic = make(chan pc.NonceInfo)
121 block = pc.MiningBlock{Data: pub.Serialize(), NonceChan: nic, Stop: nil}
122 miner = pc.NewCPUMiner(nil)
123 wg = &sync.WaitGroup{}
124
125 next pc.Uint256
126 ni pc.NonceInfo
127 )
128
129 defer func() {
130 wg.Wait()
131 close(nic)
132 }()
133
134 nis = make([]proto.Node, num)
135 for i := range nis {
136 wg.Add(1)
137 go func() {
138 defer wg.Done()
139 _ = miner.ComputeBlockNonce(block, next, diff)
140 }()
141 ni = <-nic
142 nis[i] = proto.Node{
143 ID: proto.NodeID(ni.Hash.String()),
144 Nonce: ni.Nonce,
145 PublicKey: pub,
146 }
147 next = ni.Nonce
148 next.Inc()
149 }
150
151 return
152}
153
154type keygen interface {
155 next() int

Callers 1

setupMuxParallelFunction · 0.85

Calls 7

NodeIDTypeAlias · 0.92
WaitMethod · 0.80
ComputeBlockNonceMethod · 0.80
IncMethod · 0.80
SerializeMethod · 0.45
AddMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected