( pub *ca.PublicKey, diff int, num int)
| 114 | } |
| 115 | |
| 116 | func 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 | |
| 154 | type keygen interface { |
| 155 | next() int |
no test coverage detected