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
537774e0
Commit
537774e0
authored
Feb 11, 2016
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2195 from obscuren/gpo-rpc
eth: Added GPO to suggest default gas prices
parents
1cc4bd76
725f2a4c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
15 deletions
+14
-15
api.go
eth/api.go
+13
-14
backend.go
eth/backend.go
+1
-1
No files found.
eth/api.go
View file @
537774e0
...
@@ -47,10 +47,7 @@ import (
...
@@ -47,10 +47,7 @@ import (
"gopkg.in/fatih/set.v0"
"gopkg.in/fatih/set.v0"
)
)
const
(
const
defaultGas
=
uint64
(
90000
)
defaultGasPrice
=
uint64
(
10000000000000
)
defaultGas
=
uint64
(
90000
)
)
// blockByNumber is a commonly used helper function which retrieves and returns
// blockByNumber is a commonly used helper function which retrieves and returns
// the block for the given block number, capable of handling two special blocks:
// the block for the given block number, capable of handling two special blocks:
...
@@ -820,6 +817,7 @@ func newRPCTransaction(b *types.Block, txHash common.Hash) (*RPCTransaction, err
...
@@ -820,6 +817,7 @@ func newRPCTransaction(b *types.Block, txHash common.Hash) (*RPCTransaction, err
type
PublicTransactionPoolAPI
struct
{
type
PublicTransactionPoolAPI
struct
{
eventMux
*
event
.
TypeMux
eventMux
*
event
.
TypeMux
chainDb
ethdb
.
Database
chainDb
ethdb
.
Database
gpo
*
GasPriceOracle
bc
*
core
.
BlockChain
bc
*
core
.
BlockChain
miner
*
miner
.
Miner
miner
*
miner
.
Miner
am
*
accounts
.
Manager
am
*
accounts
.
Manager
...
@@ -828,14 +826,15 @@ type PublicTransactionPoolAPI struct {
...
@@ -828,14 +826,15 @@ type PublicTransactionPoolAPI struct {
}
}
// NewPublicTransactionPoolAPI creates a new RPC service with methods specific for the transaction pool.
// NewPublicTransactionPoolAPI creates a new RPC service with methods specific for the transaction pool.
func
NewPublicTransactionPoolAPI
(
txPool
*
core
.
TxPool
,
m
*
miner
.
Miner
,
chainDb
ethdb
.
Database
,
eventMux
*
event
.
TypeMux
,
bc
*
core
.
BlockChain
,
am
*
accounts
.
Manager
)
*
PublicTransactionPoolAPI
{
func
NewPublicTransactionPoolAPI
(
e
*
Ethereum
)
*
PublicTransactionPoolAPI
{
return
&
PublicTransactionPoolAPI
{
return
&
PublicTransactionPoolAPI
{
eventMux
:
eventMux
,
eventMux
:
e
.
EventMux
(),
chainDb
:
chainDb
,
gpo
:
NewGasPriceOracle
(
e
),
bc
:
bc
,
chainDb
:
e
.
ChainDb
(),
am
:
am
,
bc
:
e
.
BlockChain
(),
txPool
:
txPool
,
am
:
e
.
AccountManager
(),
miner
:
m
,
txPool
:
e
.
TxPool
(),
miner
:
e
.
Miner
(),
}
}
}
}
...
@@ -1028,7 +1027,7 @@ func (s *PublicTransactionPoolAPI) SendTransaction(args SendTxArgs) (common.Hash
...
@@ -1028,7 +1027,7 @@ func (s *PublicTransactionPoolAPI) SendTransaction(args SendTxArgs) (common.Hash
args
.
Gas
=
rpc
.
NewHexNumber
(
defaultGas
)
args
.
Gas
=
rpc
.
NewHexNumber
(
defaultGas
)
}
}
if
args
.
GasPrice
==
nil
{
if
args
.
GasPrice
==
nil
{
args
.
GasPrice
=
rpc
.
NewHexNumber
(
defaultGasPrice
)
args
.
GasPrice
=
rpc
.
NewHexNumber
(
s
.
gpo
.
SuggestPrice
()
)
}
}
if
args
.
Value
==
nil
{
if
args
.
Value
==
nil
{
args
.
Value
=
rpc
.
NewHexNumber
(
0
)
args
.
Value
=
rpc
.
NewHexNumber
(
0
)
...
@@ -1169,7 +1168,7 @@ func (tx *Tx) UnmarshalJSON(b []byte) (err error) {
...
@@ -1169,7 +1168,7 @@ func (tx *Tx) UnmarshalJSON(b []byte) (err error) {
tx
.
GasLimit
=
rpc
.
NewHexNumber
(
0
)
tx
.
GasLimit
=
rpc
.
NewHexNumber
(
0
)
}
}
if
tx
.
GasPrice
==
nil
{
if
tx
.
GasPrice
==
nil
{
tx
.
GasPrice
=
rpc
.
NewHexNumber
(
defaultGasPrice
)
tx
.
GasPrice
=
rpc
.
NewHexNumber
(
int64
(
50000000000
)
)
}
}
if
contractCreation
{
if
contractCreation
{
...
@@ -1212,7 +1211,7 @@ func (s *PublicTransactionPoolAPI) SignTransaction(args *SignTransactionArgs) (*
...
@@ -1212,7 +1211,7 @@ func (s *PublicTransactionPoolAPI) SignTransaction(args *SignTransactionArgs) (*
args
.
Gas
=
rpc
.
NewHexNumber
(
defaultGas
)
args
.
Gas
=
rpc
.
NewHexNumber
(
defaultGas
)
}
}
if
args
.
GasPrice
==
nil
{
if
args
.
GasPrice
==
nil
{
args
.
GasPrice
=
rpc
.
NewHexNumber
(
defaultGasPrice
)
args
.
GasPrice
=
rpc
.
NewHexNumber
(
s
.
gpo
.
SuggestPrice
()
)
}
}
if
args
.
Value
==
nil
{
if
args
.
Value
==
nil
{
args
.
Value
=
rpc
.
NewHexNumber
(
0
)
args
.
Value
=
rpc
.
NewHexNumber
(
0
)
...
...
eth/backend.go
View file @
537774e0
...
@@ -269,7 +269,7 @@ func (s *Ethereum) APIs() []rpc.API {
...
@@ -269,7 +269,7 @@ func (s *Ethereum) APIs() []rpc.API {
},
{
},
{
Namespace
:
"eth"
,
Namespace
:
"eth"
,
Version
:
"1.0"
,
Version
:
"1.0"
,
Service
:
NewPublicTransactionPoolAPI
(
s
.
TxPool
(),
s
.
Miner
(),
s
.
ChainDb
(),
s
.
EventMux
(),
s
.
BlockChain
(),
s
.
AccountManager
()
),
Service
:
NewPublicTransactionPoolAPI
(
s
),
Public
:
true
,
Public
:
true
,
},
{
},
{
Namespace
:
"eth"
,
Namespace
:
"eth"
,
...
...
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