Skip to content

Commit 283c5ff

Browse files
author
eric
committed
1.dev and self-test the requirement of new economic system
2. fix bug that get gasPrice from contract
1 parent e34bb9c commit 283c5ff

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

consensus/parlia/parlia.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,12 +1078,13 @@ func (p *Parlia) distributeIncoming(val common.Address, state *state.StateDB, he
10781078
rewards = rewards.Add(rewards, blockRewards)
10791079
state.AddBalance(coinbase, blockRewards)
10801080
}
1081-
10821081
if rewards.Cmp(common.Big0) <= 0 {
10831082
return nil
10841083
}
10851084
if p.chainConfig.IsFncy2(header.Number) {
1086-
1085+
if blockRewards == nil {
1086+
blockRewards = big.NewInt(0)
1087+
}
10871088
return p.distributeRewards(rewards, blockRewards, balance, val, state, header, chain, txs, receipts, receivedTxs, usedGas, mining)
10881089
}
10891090
// remove 1/16 reward according to netmarble

core/tx_pool.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,9 +487,17 @@ func (pool *TxPool) SubscribeReannoTxsEvent(ch chan<- ReannoTxsEvent) event.Subs
487487
func (pool *TxPool) GasPrice() *big.Int {
488488
pool.mu.RLock()
489489
defer pool.mu.RUnlock()
490+
return new(big.Int).Set(pool.gasPrice)
491+
}
490492

493+
//Fncy2 Update
494+
func (pool *TxPool) GasPriceWithoutLock() *big.Int {
491495
return new(big.Int).Set(pool.gasPrice)
492496
}
497+
func (pool *TxPool) SetGasPriceWithoutLock(price *big.Int) {
498+
pool.gasPrice = price
499+
log.Info("Transaction pool price threshold updated", "price", price)
500+
}
493501

494502
// SetGasPrice updates the minimum price required by the transaction pool for a
495503
// new transaction, and drops all transactions below this threshold.
@@ -559,7 +567,6 @@ func (pool *TxPool) Content() (map[common.Address]types.Transactions, map[common
559567
func (pool *TxPool) Pending() (map[common.Address]types.Transactions, error) {
560568
pool.mu.Lock()
561569
defer pool.mu.Unlock()
562-
563570
pending := make(map[common.Address]types.Transactions)
564571
for addr, list := range pool.pending {
565572
pending[addr] = list.Flatten()
@@ -1309,7 +1316,7 @@ func (pool *TxPool) reset(oldHead, newHead *types.Header) {
13091316
if gasPrice != nil && gasPrice.Cmp(common.Big0) > 0 {
13101317
if pool.gasPrice.Cmp(gasPrice) != 0 {
13111318
log.Debug("Set gasPrice ", " old gasPrice", pool.gasPrice, " new gasPrice", gasPrice)
1312-
pool.SetGasPrice(gasPrice)
1319+
pool.SetGasPriceWithoutLock(gasPrice)
13131320
}
13141321
}
13151322
}

eth/api_backend.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,9 @@ func (b *EthAPIBackend) Downloader() *downloader.Downloader {
276276
}
277277

278278
func (b *EthAPIBackend) SuggestPrice(ctx context.Context) (*big.Int, error) {
279-
return b.gpo.SuggestPrice(ctx)
279+
//Fncy2 Update
280+
//return b.gpo.SuggestPrice(ctx)
281+
return b.eth.TxPool().GasPriceWithoutLock(), nil
280282
}
281283

282284
func (b *EthAPIBackend) Chain() *core.BlockChain {

0 commit comments

Comments
 (0)