| 412 | } |
| 413 | |
| 414 | func (pow *Full) getDAG(blockNum uint64) (d *dag) { |
| 415 | epoch := blockNum / epochLength |
| 416 | pow.mu.Lock() |
| 417 | if pow.current != nil && pow.current.epoch == epoch { |
| 418 | d = pow.current |
| 419 | } else { |
| 420 | d = &dag{epoch: epoch, test: pow.test, dir: pow.Dir} |
| 421 | pow.current = d |
| 422 | } |
| 423 | pow.mu.Unlock() |
| 424 | // wait for it to finish generating. |
| 425 | d.generate() |
| 426 | return d |
| 427 | } |
| 428 | |
| 429 | func (pow *Full) Search(block pow.Block, stop <-chan struct{}, index int) (nonce uint64, mixDigest []byte) { |
| 430 | dag := pow.getDAG(block.NumberU64()) |