aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-09-23 23:55:34 +0800
committerobscuren <geffobscura@gmail.com>2014-09-23 23:55:34 +0800
commit6800c3665a50f7ac624f4ecbaa474b8a81336143 (patch)
tree9b7e18c2a5ab32476ba891941576c36a00bb0731
parentea67d853a8a1770250a9c327ad6b8d8e1b6fa98c (diff)
downloaddexon-6800c3665a50f7ac624f4ecbaa474b8a81336143.tar.gz
dexon-6800c3665a50f7ac624f4ecbaa474b8a81336143.tar.zst
dexon-6800c3665a50f7ac624f4ecbaa474b8a81336143.zip
Re-added min gas price check on tx pool
-rw-r--r--ethchain/transaction_pool.go6
-rw-r--r--ethutil/script.go2
-rw-r--r--peer.go41
3 files changed, 37 insertions, 12 deletions
diff --git a/ethchain/transaction_pool.go b/ethchain/transaction_pool.go
index 9a6322432..0f7e85982 100644
--- a/ethchain/transaction_pool.go
+++ b/ethchain/transaction_pool.go
@@ -27,6 +27,8 @@ const (
minGasPrice = 1000000
)
+var MinGasPrice = big.NewInt(10000000000000)
+
type TxMsg struct {
Tx *Transaction
Type TxMsgTy
@@ -103,6 +105,10 @@ func (pool *TxPool) ValidateTransaction(tx *Transaction) error {
return fmt.Errorf("[TXPL] Invalid recipient. len = %d", len(tx.Recipient))
}
+ if tx.GasPrice.Cmp(MinGasPrice) >= 0 {
+ return fmt.Errorf("Gas price to low. Require %v > Got %v", MinGasPrice, tx.GasPrice)
+ }
+
// Get the sender
//sender := pool.Ethereum.StateManager().procState.GetAccount(tx.Sender())
sender := pool.Ethereum.StateManager().CurrentState().GetAccount(tx.Sender())
diff --git a/ethutil/script.go b/ethutil/script.go
index a103fb8f0..34eadff85 100644
--- a/ethutil/script.go
+++ b/ethutil/script.go
@@ -1,4 +1,4 @@
-// +build !windows
+// +build !windows !cgo
package ethutil
import (
diff --git a/peer.go b/peer.go
index 67bf4e555..34aff5ede 100644
--- a/peer.go
+++ b/peer.go
@@ -155,6 +155,8 @@ type Peer struct {
pingStartTime time.Time
lastRequestedBlock *ethchain.Block
+
+ protocolCaps *ethutil.Value
}
func NewPeer(conn net.Conn, ethereum *Ethereum, inbound bool) *Peer {
@@ -173,20 +175,22 @@ func NewPeer(conn net.Conn, ethereum *Ethereum, inbound bool) *Peer {
blocksRequested: 10,
caps: ethereum.ServerCaps(),
version: ethereum.ClientIdentity().String(),
+ protocolCaps: ethutil.NewValue(nil),
}
}
func NewOutboundPeer(addr string, ethereum *Ethereum, caps Caps) *Peer {
p := &Peer{
- outputQueue: make(chan *ethwire.Msg, outputBufferSize),
- quit: make(chan bool),
- ethereum: ethereum,
- inbound: false,
- connected: 0,
- disconnect: 0,
- port: 30303,
- caps: caps,
- version: ethereum.ClientIdentity().String(),
+ outputQueue: make(chan *ethwire.Msg, outputBufferSize),
+ quit: make(chan bool),
+ ethereum: ethereum,
+ inbound: false,
+ connected: 0,
+ disconnect: 0,
+ port: 30303,
+ caps: caps,
+ version: ethereum.ClientIdentity().String(),
+ protocolCaps: ethutil.NewValue(nil),
}
// Set up the connection in another goroutine so we don't block the main thread
@@ -568,7 +572,7 @@ func (self *Peer) FetchBlocks() {
func (self *Peer) FetchHashes() {
blockPool := self.ethereum.blockPool
- if self.td.Cmp(blockPool.td) >= 0 {
+ if self.statusKnown && self.td.Cmp(blockPool.td) >= 0 {
blockPool.td = self.td
if !blockPool.HasLatestHash() {
@@ -585,7 +589,10 @@ out:
for {
select {
case <-serviceTimer.C:
- if time.Since(self.lastBlockReceived) > 10*time.Second {
+ since := time.Since(self.lastBlockReceived)
+ if since > 10*time.Second && self.ethereum.blockPool.Len() != 0 && self.IsCap("eth") {
+ self.FetchHashes()
+ } else if since > 5*time.Second {
self.catchingUp = false
}
case <-self.quit:
@@ -789,6 +796,7 @@ func (p *Peer) handleHandshake(msg *ethwire.Msg) {
p.ethereum.PushPeer(p)
p.ethereum.reactor.Post("peerList", p.ethereum.Peers())
+ p.protocolCaps = caps
capsIt := caps.NewIterator()
var capsStrs []string
for capsIt.Next() {
@@ -806,6 +814,17 @@ func (p *Peer) handleHandshake(msg *ethwire.Msg) {
peerlogger.Debugln(p)
}
+func (self *Peer) IsCap(cap string) bool {
+ capsIt := self.protocolCaps.NewIterator()
+ for capsIt.Next() {
+ if capsIt.Value().Str() == cap {
+ return true
+ }
+ }
+
+ return false
+}
+
func (p *Peer) String() string {
var strBoundType string
if p.inbound {