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
3f94d09c
Commit
3f94d09c
authored
May 26, 2015
by
zsfelfoldi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed saving receipts
parent
6f5c6150
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
144 additions
and
54 deletions
+144
-54
main.go
cmd/geth/main.go
+6
-0
flags.go
cmd/utils/flags.go
+63
-27
block_processor.go
core/block_processor.go
+22
-0
backend.go
eth/backend.go
+36
-16
api.go
rpc/api.go
+1
-1
xeth.go
xeth/xeth.go
+16
-10
No files found.
cmd/geth/main.go
View file @
3f94d09c
...
...
@@ -256,6 +256,12 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
utils
.
PProfEanbledFlag
,
utils
.
PProfPortFlag
,
utils
.
SolcPathFlag
,
utils
.
GpoMinGasPriceFlag
,
utils
.
GpoMaxGasPriceFlag
,
utils
.
GpoFullBlockRatioFlag
,
utils
.
GpobaseStepDownFlag
,
utils
.
GpobaseStepUpFlag
,
utils
.
GpobaseCorrectionFactorFlag
,
}
app
.
Before
=
func
(
ctx
*
cli
.
Context
)
error
{
utils
.
SetupLogger
(
ctx
)
...
...
cmd/utils/flags.go
View file @
3f94d09c
...
...
@@ -276,6 +276,36 @@ var (
Usage
:
"solidity compiler to be used"
,
Value
:
"solc"
,
}
GpoMinGasPriceFlag
=
cli
.
StringFlag
{
Name
:
"gpomin"
,
Usage
:
"Minimum suggested gas price"
,
Value
:
new
(
big
.
Int
)
.
Mul
(
big
.
NewInt
(
10
),
common
.
Szabo
)
.
String
(),
}
GpoMaxGasPriceFlag
=
cli
.
StringFlag
{
Name
:
"gpomax"
,
Usage
:
"Maximum suggested gas price"
,
Value
:
new
(
big
.
Int
)
.
Mul
(
big
.
NewInt
(
1000
),
common
.
Szabo
)
.
String
(),
}
GpoFullBlockRatioFlag
=
cli
.
IntFlag
{
Name
:
"gpofull"
,
Usage
:
"Full block threshold for gas price calculation (%)"
,
Value
:
80
,
}
GpobaseStepDownFlag
=
cli
.
IntFlag
{
Name
:
"gpobasedown"
,
Usage
:
"Suggested gas price base step down ratio (1/1000)"
,
Value
:
10
,
}
GpobaseStepUpFlag
=
cli
.
IntFlag
{
Name
:
"gpobaseup"
,
Usage
:
"Suggested gas price base step up ratio (1/1000)"
,
Value
:
100
,
}
GpobaseCorrectionFactorFlag
=
cli
.
IntFlag
{
Name
:
"gpobasecf"
,
Usage
:
"Suggested gas price base correction factor (%)"
,
Value
:
110
,
}
)
// MakeNAT creates a port mapper from set command line flags.
...
...
@@ -313,33 +343,39 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
clientID
+=
"/"
+
customName
}
return
&
eth
.
Config
{
Name
:
common
.
MakeName
(
clientID
,
version
),
DataDir
:
ctx
.
GlobalString
(
DataDirFlag
.
Name
),
ProtocolVersion
:
ctx
.
GlobalInt
(
ProtocolVersionFlag
.
Name
),
GenesisNonce
:
ctx
.
GlobalInt
(
GenesisNonceFlag
.
Name
),
BlockChainVersion
:
ctx
.
GlobalInt
(
BlockchainVersionFlag
.
Name
),
SkipBcVersionCheck
:
false
,
NetworkId
:
ctx
.
GlobalInt
(
NetworkIdFlag
.
Name
),
LogFile
:
ctx
.
GlobalString
(
LogFileFlag
.
Name
),
Verbosity
:
ctx
.
GlobalInt
(
VerbosityFlag
.
Name
),
LogJSON
:
ctx
.
GlobalString
(
LogJSONFlag
.
Name
),
Etherbase
:
ctx
.
GlobalString
(
EtherbaseFlag
.
Name
),
MinerThreads
:
ctx
.
GlobalInt
(
MinerThreadsFlag
.
Name
),
AccountManager
:
MakeAccountManager
(
ctx
),
VmDebug
:
ctx
.
GlobalBool
(
VMDebugFlag
.
Name
),
MaxPeers
:
ctx
.
GlobalInt
(
MaxPeersFlag
.
Name
),
MaxPendingPeers
:
ctx
.
GlobalInt
(
MaxPendingPeersFlag
.
Name
),
Port
:
ctx
.
GlobalString
(
ListenPortFlag
.
Name
),
NAT
:
MakeNAT
(
ctx
),
NatSpec
:
ctx
.
GlobalBool
(
NatspecEnabledFlag
.
Name
),
Discovery
:
!
ctx
.
GlobalBool
(
NoDiscoverFlag
.
Name
),
NodeKey
:
MakeNodeKey
(
ctx
),
Shh
:
ctx
.
GlobalBool
(
WhisperEnabledFlag
.
Name
),
Dial
:
true
,
BootNodes
:
ctx
.
GlobalString
(
BootnodesFlag
.
Name
),
GasPrice
:
common
.
String2Big
(
ctx
.
GlobalString
(
GasPriceFlag
.
Name
)),
SolcPath
:
ctx
.
GlobalString
(
SolcPathFlag
.
Name
),
AutoDAG
:
ctx
.
GlobalBool
(
AutoDAGFlag
.
Name
)
||
ctx
.
GlobalBool
(
MiningEnabledFlag
.
Name
),
Name
:
common
.
MakeName
(
clientID
,
version
),
DataDir
:
ctx
.
GlobalString
(
DataDirFlag
.
Name
),
ProtocolVersion
:
ctx
.
GlobalInt
(
ProtocolVersionFlag
.
Name
),
GenesisNonce
:
ctx
.
GlobalInt
(
GenesisNonceFlag
.
Name
),
BlockChainVersion
:
ctx
.
GlobalInt
(
BlockchainVersionFlag
.
Name
),
SkipBcVersionCheck
:
false
,
NetworkId
:
ctx
.
GlobalInt
(
NetworkIdFlag
.
Name
),
LogFile
:
ctx
.
GlobalString
(
LogFileFlag
.
Name
),
Verbosity
:
ctx
.
GlobalInt
(
VerbosityFlag
.
Name
),
LogJSON
:
ctx
.
GlobalString
(
LogJSONFlag
.
Name
),
Etherbase
:
ctx
.
GlobalString
(
EtherbaseFlag
.
Name
),
MinerThreads
:
ctx
.
GlobalInt
(
MinerThreadsFlag
.
Name
),
AccountManager
:
MakeAccountManager
(
ctx
),
VmDebug
:
ctx
.
GlobalBool
(
VMDebugFlag
.
Name
),
MaxPeers
:
ctx
.
GlobalInt
(
MaxPeersFlag
.
Name
),
MaxPendingPeers
:
ctx
.
GlobalInt
(
MaxPendingPeersFlag
.
Name
),
Port
:
ctx
.
GlobalString
(
ListenPortFlag
.
Name
),
NAT
:
MakeNAT
(
ctx
),
NatSpec
:
ctx
.
GlobalBool
(
NatspecEnabledFlag
.
Name
),
Discovery
:
!
ctx
.
GlobalBool
(
NoDiscoverFlag
.
Name
),
NodeKey
:
MakeNodeKey
(
ctx
),
Shh
:
ctx
.
GlobalBool
(
WhisperEnabledFlag
.
Name
),
Dial
:
true
,
BootNodes
:
ctx
.
GlobalString
(
BootnodesFlag
.
Name
),
GasPrice
:
common
.
String2Big
(
ctx
.
GlobalString
(
GasPriceFlag
.
Name
)),
GpoMinGasPrice
:
common
.
String2Big
(
ctx
.
GlobalString
(
GpoMinGasPriceFlag
.
Name
)),
GpoMaxGasPrice
:
common
.
String2Big
(
ctx
.
GlobalString
(
GpoMaxGasPriceFlag
.
Name
)),
GpoFullBlockRatio
:
ctx
.
GlobalInt
(
GpoFullBlockRatioFlag
.
Name
),
GpobaseStepDown
:
ctx
.
GlobalInt
(
GpobaseStepDownFlag
.
Name
),
GpobaseStepUp
:
ctx
.
GlobalInt
(
GpobaseStepUpFlag
.
Name
),
GpobaseCorrectionFactor
:
ctx
.
GlobalInt
(
GpobaseCorrectionFactorFlag
.
Name
),
SolcPath
:
ctx
.
GlobalString
(
SolcPathFlag
.
Name
),
AutoDAG
:
ctx
.
GlobalBool
(
AutoDAGFlag
.
Name
)
||
ctx
.
GlobalBool
(
MiningEnabledFlag
.
Name
),
}
}
...
...
core/block_processor.go
View file @
3f94d09c
...
...
@@ -260,9 +260,31 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (logs st
putTx
(
sm
.
extraDb
,
tx
,
block
,
uint64
(
i
))
}
receiptsRlp
:=
receipts
.
RlpEncode
()
/*if len(receipts) > 0 {
glog.V(logger.Info).Infof("Saving %v receipts, rlp len is %v\n", len(receipts), len(receiptsRlp))
}*/
sm
.
extraDb
.
Put
(
append
(
receiptsPre
,
block
.
Hash
()
.
Bytes
()
...
),
receiptsRlp
)
return
state
.
Logs
(),
nil
}
func
(
self
*
BlockProcessor
)
GetBlockReceipts
(
bhash
common
.
Hash
)
(
receipts
types
.
Receipts
,
err
error
)
{
var
rdata
[]
byte
rdata
,
err
=
self
.
extraDb
.
Get
(
append
(
receiptsPre
,
bhash
[
:
]
...
))
if
err
==
nil
{
err
=
rlp
.
DecodeBytes
(
rdata
,
&
receipts
)
}
else
{
glog
.
V
(
logger
.
Detail
)
.
Infof
(
"GetBlockReceipts error %v
\n
"
,
err
)
}
/*if len(receipts) > 0 {
glog.V(logger.Info).Infof("GBR len %v\n", len(receipts))
}*/
return
}
// See YP section 4.3.4. "Block Header Validity"
// Validates a block. Returns an error if the block is invalid.
func
(
sm
*
BlockProcessor
)
ValidateHeader
(
block
,
parent
*
types
.
Header
,
checkPow
bool
)
error
{
...
...
eth/backend.go
View file @
3f94d09c
...
...
@@ -93,6 +93,13 @@ type Config struct {
AccountManager
*
accounts
.
Manager
SolcPath
string
GpoMinGasPrice
*
big
.
Int
GpoMaxGasPrice
*
big
.
Int
GpoFullBlockRatio
int
GpobaseStepDown
int
GpobaseStepUp
int
GpobaseCorrectionFactor
int
// NewDB is used to create databases.
// If nil, the default is to create leveldb databases on disk.
NewDB
func
(
path
string
)
(
common
.
Database
,
error
)
...
...
@@ -197,6 +204,13 @@ type Ethereum struct {
SolcPath
string
solc
*
compiler
.
Solidity
GpoMinGasPrice
*
big
.
Int
GpoMaxGasPrice
*
big
.
Int
GpoFullBlockRatio
int
GpobaseStepDown
int
GpobaseStepUp
int
GpobaseCorrectionFactor
int
net
*
p2p
.
Server
eventMux
*
event
.
TypeMux
miner
*
miner
.
Miner
...
...
@@ -266,22 +280,28 @@ func New(config *Config) (*Ethereum, error) {
glog
.
V
(
logger
.
Info
)
.
Infof
(
"Blockchain DB Version: %d"
,
config
.
BlockChainVersion
)
eth
:=
&
Ethereum
{
shutdownChan
:
make
(
chan
bool
),
databasesClosed
:
make
(
chan
bool
),
blockDb
:
blockDb
,
stateDb
:
stateDb
,
extraDb
:
extraDb
,
eventMux
:
&
event
.
TypeMux
{},
accountManager
:
config
.
AccountManager
,
DataDir
:
config
.
DataDir
,
etherbase
:
common
.
HexToAddress
(
config
.
Etherbase
),
clientVersion
:
config
.
Name
,
// TODO should separate from Name
ethVersionId
:
config
.
ProtocolVersion
,
netVersionId
:
config
.
NetworkId
,
NatSpec
:
config
.
NatSpec
,
MinerThreads
:
config
.
MinerThreads
,
SolcPath
:
config
.
SolcPath
,
AutoDAG
:
config
.
AutoDAG
,
shutdownChan
:
make
(
chan
bool
),
databasesClosed
:
make
(
chan
bool
),
blockDb
:
blockDb
,
stateDb
:
stateDb
,
extraDb
:
extraDb
,
eventMux
:
&
event
.
TypeMux
{},
accountManager
:
config
.
AccountManager
,
DataDir
:
config
.
DataDir
,
etherbase
:
common
.
HexToAddress
(
config
.
Etherbase
),
clientVersion
:
config
.
Name
,
// TODO should separate from Name
ethVersionId
:
config
.
ProtocolVersion
,
netVersionId
:
config
.
NetworkId
,
NatSpec
:
config
.
NatSpec
,
MinerThreads
:
config
.
MinerThreads
,
SolcPath
:
config
.
SolcPath
,
AutoDAG
:
config
.
AutoDAG
,
GpoMinGasPrice
:
config
.
GpoMinGasPrice
,
GpoMaxGasPrice
:
config
.
GpoMaxGasPrice
,
GpoFullBlockRatio
:
config
.
GpoFullBlockRatio
,
GpobaseStepDown
:
config
.
GpobaseStepDown
,
GpobaseStepUp
:
config
.
GpobaseStepUp
,
GpobaseCorrectionFactor
:
config
.
GpobaseCorrectionFactor
,
}
eth
.
pow
=
ethash
.
New
()
...
...
rpc/api.go
View file @
3f94d09c
...
...
@@ -59,7 +59,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
case
"eth_mining"
:
*
reply
=
api
.
xeth
()
.
IsMining
()
case
"eth_gasPrice"
:
v
:=
xeth
.
DefaultGasPrice
()
v
:=
api
.
xeth
()
.
DefaultGasPrice
()
*
reply
=
newHexNum
(
v
.
Bytes
())
case
"eth_accounts"
:
*
reply
=
api
.
xeth
()
.
Accounts
()
...
...
xeth/xeth.go
View file @
3f94d09c
...
...
@@ -39,8 +39,11 @@ const (
LogFilterTy
)
func
DefaultGas
()
*
big
.
Int
{
return
new
(
big
.
Int
)
.
Set
(
defaultGas
)
}
func
DefaultGasPrice
()
*
big
.
Int
{
return
new
(
big
.
Int
)
.
Set
(
defaultGasPrice
)
}
func
DefaultGas
()
*
big
.
Int
{
return
new
(
big
.
Int
)
.
Set
(
defaultGas
)
}
func
(
self
*
XEth
)
DefaultGasPrice
()
*
big
.
Int
{
return
self
.
gpo
.
SuggestPrice
()
}
type
XEth
struct
{
backend
*
eth
.
Ethereum
...
...
@@ -68,6 +71,8 @@ type XEth struct {
// register map[string][]*interface{} // TODO improve return type
agent
*
miner
.
RemoteAgent
gpo
*
eth
.
GasPriceOracle
}
func
NewTest
(
eth
*
eth
.
Ethereum
,
frontend
Frontend
)
*
XEth
{
...
...
@@ -80,22 +85,23 @@ func NewTest(eth *eth.Ethereum, frontend Frontend) *XEth {
// New creates an XEth that uses the given frontend.
// If a nil Frontend is provided, a default frontend which
// confirms all transactions will be used.
func
New
(
eth
*
eth
.
Ethereum
,
frontend
Frontend
)
*
XEth
{
func
New
(
eth
ereum
*
eth
.
Ethereum
,
frontend
Frontend
)
*
XEth
{
xeth
:=
&
XEth
{
backend
:
eth
,
backend
:
eth
ereum
,
frontend
:
frontend
,
quit
:
make
(
chan
struct
{}),
filterManager
:
filter
.
NewFilterManager
(
eth
.
EventMux
()),
filterManager
:
filter
.
NewFilterManager
(
eth
ereum
.
EventMux
()),
logQueue
:
make
(
map
[
int
]
*
logQueue
),
blockQueue
:
make
(
map
[
int
]
*
hashQueue
),
transactionQueue
:
make
(
map
[
int
]
*
hashQueue
),
messages
:
make
(
map
[
int
]
*
whisperFilter
),
agent
:
miner
.
NewRemoteAgent
(),
gpo
:
eth
.
NewGasPriceOracle
(
ethereum
),
}
if
eth
.
Whisper
()
!=
nil
{
xeth
.
whisper
=
NewWhisper
(
eth
.
Whisper
())
if
eth
ereum
.
Whisper
()
!=
nil
{
xeth
.
whisper
=
NewWhisper
(
eth
ereum
.
Whisper
())
}
eth
.
Miner
()
.
Register
(
xeth
.
agent
)
eth
ereum
.
Miner
()
.
Register
(
xeth
.
agent
)
if
frontend
==
nil
{
xeth
.
frontend
=
dummyFrontend
{}
}
...
...
@@ -829,7 +835,7 @@ func (self *XEth) Call(fromStr, toStr, valueStr, gasStr, gasPriceStr, dataStr st
}
if
msg
.
gasPrice
.
Cmp
(
big
.
NewInt
(
0
))
==
0
{
msg
.
gasPrice
=
DefaultGasPrice
()
msg
.
gasPrice
=
self
.
DefaultGasPrice
()
}
block
:=
self
.
CurrentBlock
()
...
...
@@ -898,7 +904,7 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS
}
if
len
(
gasPriceStr
)
==
0
{
price
=
DefaultGasPrice
()
price
=
self
.
DefaultGasPrice
()
}
else
{
price
=
common
.
Big
(
gasPriceStr
)
}
...
...
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