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

Function GetPubKeyNonce

crypto/asymmetric/keypair.go:188–212  ·  view source on GitHub ↗

GetPubKeyNonce will make his best effort to find a difficult enough nonce.

(
	publicKey *PublicKey,
	difficulty int,
	timeThreshold time.Duration,
	quit chan struct{})

Source from the content-addressed store, hash-verified

186// GetPubKeyNonce will make his best effort to find a difficult enough
187// nonce.
188func GetPubKeyNonce(
189 publicKey *PublicKey,
190 difficulty int,
191 timeThreshold time.Duration,
192 quit chan struct{}) (nonce mine.NonceInfo) {
193
194 miner := mine.NewCPUMiner(quit)
195 nonceCh := make(chan mine.NonceInfo)
196 // if miner finished his work before timeThreshold
197 // make sure writing to the Stop chan non-blocking.
198 stop := make(chan struct{}, 1)
199 block := mine.MiningBlock{
200 Data: publicKey.Serialize(),
201 NonceChan: nonceCh,
202 Stop: stop,
203 }
204
205 go miner.ComputeBlockNonce(block, mine.Uint256{}, difficulty)
206
207 time.Sleep(timeThreshold)
208 // stop miner
209 block.Stop <- struct{}{}
210
211 return <-block.NonceChan
212}

Callers 7

InitNodeCryptoInfoMethod · 0.92
TestETLSBugFunction · 0.92
TestEncPingFindNeighborFunction · 0.92
TestGetPubKeyNonceFunction · 0.85
TestGetThePubKeyNonceFunction · 0.85

Calls 2

ComputeBlockNonceMethod · 0.95
SerializeMethod · 0.45

Tested by 6

TestETLSBugFunction · 0.74
TestEncPingFindNeighborFunction · 0.74
TestGetPubKeyNonceFunction · 0.68
TestGetThePubKeyNonceFunction · 0.68