Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
6800c366
Commit
6800c366
authored
Sep 23, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-added min gas price check on tx pool
parent
ea67d853
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
12 deletions
+37
-12
transaction_pool.go
ethchain/transaction_pool.go
+6
-0
script.go
ethutil/script.go
+1
-1
peer.go
peer.go
+30
-11
No files found.
ethchain/transaction_pool.go
View file @
6800c366
...
@@ -27,6 +27,8 @@ const (
...
@@ -27,6 +27,8 @@ const (
minGasPrice
=
1000000
minGasPrice
=
1000000
)
)
var
MinGasPrice
=
big
.
NewInt
(
10000000000000
)
type
TxMsg
struct
{
type
TxMsg
struct
{
Tx
*
Transaction
Tx
*
Transaction
Type
TxMsgTy
Type
TxMsgTy
...
@@ -103,6 +105,10 @@ func (pool *TxPool) ValidateTransaction(tx *Transaction) error {
...
@@ -103,6 +105,10 @@ func (pool *TxPool) ValidateTransaction(tx *Transaction) error {
return
fmt
.
Errorf
(
"[TXPL] Invalid recipient. len = %d"
,
len
(
tx
.
Recipient
))
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
// Get the sender
//sender := pool.Ethereum.StateManager().procState.GetAccount(tx.Sender())
//sender := pool.Ethereum.StateManager().procState.GetAccount(tx.Sender())
sender
:=
pool
.
Ethereum
.
StateManager
()
.
CurrentState
()
.
GetAccount
(
tx
.
Sender
())
sender
:=
pool
.
Ethereum
.
StateManager
()
.
CurrentState
()
.
GetAccount
(
tx
.
Sender
())
...
...
ethutil/script.go
View file @
6800c366
// +build !windows
// +build !windows
!cgo
package
ethutil
package
ethutil
import
(
import
(
...
...
peer.go
View file @
6800c366
...
@@ -155,6 +155,8 @@ type Peer struct {
...
@@ -155,6 +155,8 @@ type Peer struct {
pingStartTime
time
.
Time
pingStartTime
time
.
Time
lastRequestedBlock
*
ethchain
.
Block
lastRequestedBlock
*
ethchain
.
Block
protocolCaps
*
ethutil
.
Value
}
}
func
NewPeer
(
conn
net
.
Conn
,
ethereum
*
Ethereum
,
inbound
bool
)
*
Peer
{
func
NewPeer
(
conn
net
.
Conn
,
ethereum
*
Ethereum
,
inbound
bool
)
*
Peer
{
...
@@ -173,20 +175,22 @@ 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
,
blocksRequested
:
10
,
caps
:
ethereum
.
ServerCaps
(),
caps
:
ethereum
.
ServerCaps
(),
version
:
ethereum
.
ClientIdentity
()
.
String
(),
version
:
ethereum
.
ClientIdentity
()
.
String
(),
protocolCaps
:
ethutil
.
NewValue
(
nil
),
}
}
}
}
func
NewOutboundPeer
(
addr
string
,
ethereum
*
Ethereum
,
caps
Caps
)
*
Peer
{
func
NewOutboundPeer
(
addr
string
,
ethereum
*
Ethereum
,
caps
Caps
)
*
Peer
{
p
:=
&
Peer
{
p
:=
&
Peer
{
outputQueue
:
make
(
chan
*
ethwire
.
Msg
,
outputBufferSize
),
outputQueue
:
make
(
chan
*
ethwire
.
Msg
,
outputBufferSize
),
quit
:
make
(
chan
bool
),
quit
:
make
(
chan
bool
),
ethereum
:
ethereum
,
ethereum
:
ethereum
,
inbound
:
false
,
inbound
:
false
,
connected
:
0
,
connected
:
0
,
disconnect
:
0
,
disconnect
:
0
,
port
:
30303
,
port
:
30303
,
caps
:
caps
,
caps
:
caps
,
version
:
ethereum
.
ClientIdentity
()
.
String
(),
version
:
ethereum
.
ClientIdentity
()
.
String
(),
protocolCaps
:
ethutil
.
NewValue
(
nil
),
}
}
// Set up the connection in another goroutine so we don't block the main thread
// Set up the connection in another goroutine so we don't block the main thread
...
@@ -568,7 +572,7 @@ func (self *Peer) FetchBlocks() {
...
@@ -568,7 +572,7 @@ func (self *Peer) FetchBlocks() {
func
(
self
*
Peer
)
FetchHashes
()
{
func
(
self
*
Peer
)
FetchHashes
()
{
blockPool
:=
self
.
ethereum
.
blockPool
blockPool
:=
self
.
ethereum
.
blockPool
if
self
.
td
.
Cmp
(
blockPool
.
td
)
>=
0
{
if
self
.
statusKnown
&&
self
.
td
.
Cmp
(
blockPool
.
td
)
>=
0
{
blockPool
.
td
=
self
.
td
blockPool
.
td
=
self
.
td
if
!
blockPool
.
HasLatestHash
()
{
if
!
blockPool
.
HasLatestHash
()
{
...
@@ -585,7 +589,10 @@ out:
...
@@ -585,7 +589,10 @@ out:
for
{
for
{
select
{
select
{
case
<-
serviceTimer
.
C
:
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
self
.
catchingUp
=
false
}
}
case
<-
self
.
quit
:
case
<-
self
.
quit
:
...
@@ -789,6 +796,7 @@ func (p *Peer) handleHandshake(msg *ethwire.Msg) {
...
@@ -789,6 +796,7 @@ func (p *Peer) handleHandshake(msg *ethwire.Msg) {
p
.
ethereum
.
PushPeer
(
p
)
p
.
ethereum
.
PushPeer
(
p
)
p
.
ethereum
.
reactor
.
Post
(
"peerList"
,
p
.
ethereum
.
Peers
())
p
.
ethereum
.
reactor
.
Post
(
"peerList"
,
p
.
ethereum
.
Peers
())
p
.
protocolCaps
=
caps
capsIt
:=
caps
.
NewIterator
()
capsIt
:=
caps
.
NewIterator
()
var
capsStrs
[]
string
var
capsStrs
[]
string
for
capsIt
.
Next
()
{
for
capsIt
.
Next
()
{
...
@@ -806,6 +814,17 @@ func (p *Peer) handleHandshake(msg *ethwire.Msg) {
...
@@ -806,6 +814,17 @@ func (p *Peer) handleHandshake(msg *ethwire.Msg) {
peerlogger
.
Debugln
(
p
)
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
{
func
(
p
*
Peer
)
String
()
string
{
var
strBoundType
string
var
strBoundType
string
if
p
.
inbound
{
if
p
.
inbound
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment