MCPcopy Create free account
hub / github.com/SmartPool/smartpool-client / SetEpochData

Method SetEpochData

ethereum/contract.go:77–105  ·  view source on GitHub ↗
(epochs ...int)

Source from the content-addressed store, hash-verified

75}
76
77func (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
107func NewContract(client ContractClient) *Contract {
108 return &Contract{client}

Callers 1

RunFunction · 0.95

Implementers 3

testContractprotocol/test_contract.go
Contractethereum/contract.go
TestPoolSessionethereum/geth/generated_test_pool.go

Calls 6

RootHashMethod · 0.95
processDuringReadFunction · 0.85
FinalizeMethod · 0.80
PrintfMethod · 0.65
SetEpochDataMethod · 0.65
BigMethod · 0.45

Tested by

no test coverage detected