From d247be24bcda7270a22dbbc3ce0e4bd2f41f6caf Mon Sep 17 00:00:00 2001 From: pingke Date: Thu, 30 Nov 2023 20:37:17 +0800 Subject: [PATCH] expose miningInfo Attributes to other package --- ethstorage/miner/l1_mining_api.go | 6 +++--- ethstorage/miner/miner.go | 12 ++++++------ ethstorage/miner/worker.go | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ethstorage/miner/l1_mining_api.go b/ethstorage/miner/l1_mining_api.go index 35b07033..1c38dd78 100644 --- a/ethstorage/miner/l1_mining_api.go +++ b/ethstorage/miner/l1_mining_api.go @@ -52,9 +52,9 @@ func (m *l1MiningAPI) GetMiningInfo(ctx context.Context, contract common.Address return nil, err } mi := &miningInfo{ - lastMineTime: res[0].(*big.Int).Uint64(), - difficulty: res[1].(*big.Int), - blockMined: res[2].(*big.Int), + LastMineTime: res[0].(*big.Int).Uint64(), + Difficulty: res[1].(*big.Int), + BlockMined: res[2].(*big.Int), } return mi, nil } diff --git a/ethstorage/miner/miner.go b/ethstorage/miner/miner.go index ab73a321..71580b48 100644 --- a/ethstorage/miner/miner.go +++ b/ethstorage/miner/miner.go @@ -31,17 +31,17 @@ type MiningProver interface { } type miningInfo struct { - lastMineTime uint64 - difficulty *big.Int - blockMined *big.Int + LastMineTime uint64 + Difficulty *big.Int + BlockMined *big.Int } func (a *miningInfo) String() string { return fmt.Sprintf( "LastMineTime: %d, Difficulty: %s, BlockMined: %s", - a.lastMineTime, - a.difficulty.String(), - a.blockMined.String(), + a.LastMineTime, + a.Difficulty.String(), + a.BlockMined.String(), ) } diff --git a/ethstorage/miner/worker.go b/ethstorage/miner/worker.go index 37607a0f..371e617c 100644 --- a/ethstorage/miner/worker.go +++ b/ethstorage/miner/worker.go @@ -235,11 +235,11 @@ func (w *worker) updateDifficulty(shardIdx, blockTime uint64) (*big.Int, error) w.lg.Warn("Failed to get es mining info", "error", err.Error()) return nil, err } - w.lg.Info("Mining info retrieved", "shard", shardIdx, "lastMineTime", info.lastMineTime, "difficulty", info.difficulty, "proofsSubmitted", info.blockMined) + w.lg.Info("Mining info retrieved", "shard", shardIdx, "LastMineTime", info.LastMineTime, "Difficulty", info.Difficulty, "proofsSubmitted", info.BlockMined) reqDiff := new(big.Int).Div(maxUint256, expectedDiff( - info.lastMineTime, + info.LastMineTime, blockTime, - info.difficulty, + info.Difficulty, w.config.Cutoff, w.config.DiffAdjDivisor, w.config.MinimumDiff,