diff options
Diffstat (limited to 'eth')
| -rw-r--r-- | eth/backend.go | 7 | ||||
| -rw-r--r-- | eth/gasprice.go | 23 |
2 files changed, 17 insertions, 13 deletions
diff --git a/eth/backend.go b/eth/backend.go index 953a150ad..2b21a7c96 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -61,10 +61,11 @@ var ( defaultBootNodes = []*discover.Node{ // ETH/DEV Go Bootnodes - discover.MustParseNode("enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303"), - discover.MustParseNode("enode://de471bccee3d042261d52e9bff31458daecc406142b401d4cd848f677479f73104b9fdeb090af9583d3391b7f10cb2ba9e26865dd5fca4fcdc0fb1e3b723c786@54.94.239.50:30303"), + discover.MustParseNode("enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303"), // IE + discover.MustParseNode("enode://de471bccee3d042261d52e9bff31458daecc406142b401d4cd848f677479f73104b9fdeb090af9583d3391b7f10cb2ba9e26865dd5fca4fcdc0fb1e3b723c786@54.94.239.50:30303"), // BR + discover.MustParseNode("enode://1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082@52.74.57.123:30303"), // SG // ETH/DEV cpp-ethereum (poc-9.ethdev.com) - discover.MustParseNode("enode://487611428e6c99a11a9795a6abe7b529e81315ca6aad66e2a2fc76e3adf263faba0d35466c2f8f68d561dbefa8878d4df5f1f2ddb1fbeab7f42ffb8cd328bd4a@5.1.83.226:30303"), + discover.MustParseNode("enode://979b7fa28feeb35a4741660a16076f1943202cb72b6af70d327f053e248bab9ba81760f39d0701ef1d8f89cc1fbd2cacba0710a12cd5314d5e0c9021aa3637f9@5.1.83.226:30303"), } staticNodes = "static-nodes.json" // Path within <datadir> to search for the static node list diff --git a/eth/gasprice.go b/eth/gasprice.go index 031098e9a..3caad73c6 100644 --- a/eth/gasprice.go +++ b/eth/gasprice.go @@ -37,12 +37,11 @@ type blockPriceInfo struct { type GasPriceOracle struct { eth *Ethereum chain *core.ChainManager - pool *core.TxPool events event.Subscription blocks map[uint64]*blockPriceInfo firstProcessed, lastProcessed uint64 lastBaseMutex sync.Mutex - lastBase *big.Int + lastBase, minBase *big.Int } func NewGasPriceOracle(eth *Ethereum) (self *GasPriceOracle) { @@ -50,13 +49,15 @@ func NewGasPriceOracle(eth *Ethereum) (self *GasPriceOracle) { self.blocks = make(map[uint64]*blockPriceInfo) self.eth = eth self.chain = eth.chainManager - self.pool = eth.txPool self.events = eth.EventMux().Subscribe( core.ChainEvent{}, core.ChainSplitEvent{}, - core.TxPreEvent{}, - core.TxPostEvent{}, ) + + minbase := new(big.Int).Mul(self.eth.GpoMinGasPrice, big.NewInt(100)) + minbase = minbase.Div(minbase, big.NewInt(int64(self.eth.GpobaseCorrectionFactor))) + self.minBase = minbase + self.processPastBlocks() go self.listenLoop() return @@ -93,8 +94,6 @@ func (self *GasPriceOracle) listenLoop() { self.processBlock(ev.Block) case core.ChainSplitEvent: self.processBlock(ev.Block) - case core.TxPreEvent: - case core.TxPostEvent: } } self.events.Unsubscribe() @@ -131,6 +130,10 @@ func (self *GasPriceOracle) processBlock(block *types.Block) { newBase := new(big.Int).Mul(lastBase, big.NewInt(1000000+crand)) newBase.Div(newBase, big.NewInt(1000000)) + if newBase.Cmp(self.minBase) < 0 { + newBase = self.minBase + } + bpi := self.blocks[i] if bpi == nil { bpi = &blockPriceInfo{} @@ -146,7 +149,7 @@ func (self *GasPriceOracle) processBlock(block *types.Block) { // returns the lowers possible price with which a tx was or could have been included func (self *GasPriceOracle) lowestPrice(block *types.Block) *big.Int { - gasUsed := new(big.Int) + gasUsed := big.NewInt(0) receipts := self.eth.BlockProcessor().GetBlockReceipts(block.Hash()) if len(receipts) > 0 { @@ -158,12 +161,12 @@ func (self *GasPriceOracle) lowestPrice(block *types.Block) *big.Int { if new(big.Int).Mul(gasUsed, big.NewInt(100)).Cmp(new(big.Int).Mul(block.GasLimit(), big.NewInt(int64(self.eth.GpoFullBlockRatio)))) < 0 { // block is not full, could have posted a tx with MinGasPrice - return self.eth.GpoMinGasPrice + return big.NewInt(0) } txs := block.Transactions() if len(txs) == 0 { - return self.eth.GpoMinGasPrice + return big.NewInt(0) } // block is full, find smallest gasPrice minPrice := txs[0].GasPrice() |
