Skip to content
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.

Commit

Permalink
Deprecate klay_gasPriceAt
Browse files Browse the repository at this point in the history
  • Loading branch information
ian0371 committed Jun 13, 2023
1 parent b4593f0 commit 6fb3afc
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 54 deletions.
7 changes: 0 additions & 7 deletions console/web3ext/web3ext.go
Original file line number Diff line number Diff line change
Expand Up @@ -885,13 +885,6 @@ web3._extend({
params: 1,
inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter]
}),
new web3._extend.Method({
name: 'gasPriceAt',
call: 'klay_gasPriceAt',
params: 1,
inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter],
outputFormatter: web3._extend.formatters.outputBigNumberFormatter
}),
new web3._extend.Method({
name: 'getRewards',
call: 'klay_getRewards',
Expand Down
47 changes: 0 additions & 47 deletions governance/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"time"

"github.com/klaytn/klaytn/common"
"github.com/klaytn/klaytn/common/hexutil"
"github.com/klaytn/klaytn/networks/rpc"
"github.com/klaytn/klaytn/params"
"github.com/klaytn/klaytn/reward"
Expand Down Expand Up @@ -82,43 +81,6 @@ func (api *GovernanceKlayAPI) NodeAddress() common.Address {
return api.governance.NodeAddress()
}

// GasPriceAt returns the base fee of the given block in peb,
// or returns unit price by using governance if there is no base fee set in header,
// or returns gas price of txpool if the block is pending block.
func (api *GovernanceKlayAPI) GasPriceAt(num *rpc.BlockNumber) (*hexutil.Big, error) {
if num == nil || *num == rpc.LatestBlockNumber {
header := api.chain.CurrentBlock().Header()
if header.BaseFee == nil {
pset, err := api.governance.EffectiveParams(header.Number.Uint64() + 1)
if err != nil {
return nil, err
}
return (*hexutil.Big)(new(big.Int).SetUint64(pset.UnitPrice())), nil
}
return (*hexutil.Big)(header.BaseFee), nil
} else if *num == rpc.PendingBlockNumber {
txpool := api.governance.GetTxPool()
return (*hexutil.Big)(txpool.GasPrice()), nil
} else {
blockNum := num.Uint64()

// Return the BaseFee in header at the block number
header := api.chain.GetHeaderByNumber(blockNum)
if blockNum > api.chain.CurrentBlock().NumberU64() || header == nil {
return nil, errUnknownBlock
} else if header.BaseFee != nil {
return (*hexutil.Big)(header.BaseFee), nil
}

// Return the UnitPrice in governance data at the block number
if ret, err := api.GasPriceAtNumber(blockNum); err != nil {
return nil, err
} else {
return (*hexutil.Big)(new(big.Int).SetUint64(ret)), nil
}
}
}

// GetRewards returns detailed information of the block reward at a given block number.
func (api *GovernanceKlayAPI) GetRewards(num *rpc.BlockNumber) (*reward.RewardSpec, error) {
blockNumber := uint64(0)
Expand Down Expand Up @@ -476,15 +438,6 @@ func (api *GovernanceAPI) isGovernanceModeBallot() bool {
return gMode == params.GovernanceMode_Ballot
}

func (api *GovernanceKlayAPI) GasPriceAtNumber(num uint64) (uint64, error) {
pset, err := api.governance.EffectiveParams(num)
if err != nil {
logger.Error("Failed to retrieve unit price", "err", err)
return 0, err
}
return pset.UnitPrice(), nil
}

// Disabled APIs
// func (api *GovernanceKlayAPI) GetTxGasHumanReadable(num *rpc.BlockNumber) (uint64, error) {
// if num == nil || *num == rpc.LatestBlockNumber || *num == rpc.PendingBlockNumber {
Expand Down

0 comments on commit 6fb3afc

Please sign in to comment.