MCPcopy Create free account
hub / github.com/ethstorage/es-node / getMiningInfo

Function getMiningInfo

cmd/es-node/utils.go:167–191  ·  view source on GitHub ↗
(ctx context.Context, client *ethclient.Client, contract common.Address, shardIdx uint64)

Source from the content-addressed store, hash-verified

165}
166
167func getMiningInfo(ctx context.Context, client *ethclient.Client, contract common.Address, shardIdx uint64) ([]interface{}, error) {
168 uint256Type, _ := abi.NewType("uint256", "", nil)
169 dataField, _ := abi.Arguments{{Type: uint256Type}}.Pack(new(big.Int).SetUint64(shardIdx))
170 h := crypto.Keccak256Hash([]byte(`infos(uint256)`))
171 calldata := append(h[0:4], dataField...)
172 msg := ethereum.CallMsg{
173 To: &contract,
174 Data: calldata,
175 }
176 bs, err := client.CallContract(ctx, msg, nil)
177 if err != nil {
178 lg.Error("Failed to call contract", "error", err.Error())
179 return nil, err
180 }
181 res, _ := abi.Arguments{
182 {Type: uint256Type},
183 {Type: uint256Type},
184 {Type: uint256Type},
185 }.UnpackValues(bs)
186 if res == nil || len(res) < 3 {
187 lg.Error("Query mining info by shard", "error", "invalid result", "result", res)
188 return nil, fmt.Errorf("invalid result: %v", res)
189 }
190 return res, nil
191}
192
193func createDataFile(cfg *storage.StorageConfig, shardIdxList []uint64, datadir string, encodingType int) ([]string, error) {
194 lg.Info("Creating data files", "shardIdxList", shardIdxList, "dataDir", datadir)

Callers 1

getDifficultyFunction · 0.85

Calls 1

ErrorMethod · 0.45

Tested by

no test coverage detected