(epochs ...int)
| 75 | } |
| 76 | |
| 77 | func (c *Contract) SetEpochData(epochs ...int) error { |
| 78 | roots := []*big.Int{} |
| 79 | sizes := []uint64{} |
| 80 | depths := []uint64{} |
| 81 | eps := []*big.Int{} |
| 82 | for _, epoch := range epochs { |
| 83 | eps = append(eps, big.NewInt(int64(epoch))) |
| 84 | smartpool.Output.Printf("Checking DAG file. Generate if needed...\n") |
| 85 | fullSize, _ := ethash.MakeDAGWithSize(uint64(epoch*30000), "") |
| 86 | fullSizeIn128Resolution := fullSize / 128 |
| 87 | sizes = append(sizes, fullSizeIn128Resolution) |
| 88 | seedHash, err := ethash.GetSeedHash(uint64(epoch * 30000)) |
| 89 | if err != nil { |
| 90 | panic(err) |
| 91 | } |
| 92 | path := filepath.Join( |
| 93 | ethash.DefaultDir, |
| 94 | fmt.Sprintf("full-R%s-%s", "23", hex.EncodeToString(seedHash[:8])), |
| 95 | ) |
| 96 | mt := mtree.NewDagTree() |
| 97 | processDuringRead(path, mt) |
| 98 | mt.Finalize() |
| 99 | merkleRoot := mt.RootHash().Big() |
| 100 | roots = append(roots, merkleRoot) |
| 101 | branchDepth := len(fmt.Sprintf("%b", fullSizeIn128Resolution-1)) |
| 102 | depths = append(depths, uint64(branchDepth)) |
| 103 | } |
| 104 | return c.client.SetEpochData(roots, sizes, depths, eps) |
| 105 | } |
| 106 | |
| 107 | func NewContract(client ContractClient) *Contract { |
| 108 | return &Contract{client} |
no test coverage detected