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
f2f65c1a
Commit
f2f65c1a
authored
Mar 23, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop
parents
c8e9ca04
90c710fd
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
74 additions
and
38 deletions
+74
-38
js.go
cmd/ethereum/js.go
+1
-0
main.go
cmd/ethtest/main.go
+4
-5
backend.go
eth/backend.go
+15
-12
logsystem.go
logger/logsystem.go
+6
-6
testlog_test.go
p2p/testlog_test.go
+2
-5
api.go
rpc/api.go
+5
-1
args.go
rpc/args.go
+4
-5
args_test.go
rpc/args_test.go
+33
-2
init.go
tests/helper/init.go
+1
-1
xeth.go
xeth/xeth.go
+3
-1
No files found.
cmd/ethereum/js.go
View file @
f2f65c1a
...
@@ -91,6 +91,7 @@ func newJSRE(ethereum *eth.Ethereum, libPath string) *jsre {
...
@@ -91,6 +91,7 @@ func newJSRE(ethereum *eth.Ethereum, libPath string) *jsre {
func
(
js
*
jsre
)
apiBindings
()
{
func
(
js
*
jsre
)
apiBindings
()
{
ethApi
:=
rpc
.
NewEthereumApi
(
js
.
xeth
,
js
.
ethereum
.
DataDir
)
ethApi
:=
rpc
.
NewEthereumApi
(
js
.
xeth
,
js
.
ethereum
.
DataDir
)
ethApi
.
Close
()
//js.re.Bind("jeth", rpc.NewJeth(ethApi, js.re.ToVal))
//js.re.Bind("jeth", rpc.NewJeth(ethApi, js.re.ToVal))
jeth
:=
rpc
.
NewJeth
(
ethApi
,
js
.
re
.
ToVal
,
js
.
re
)
jeth
:=
rpc
.
NewJeth
(
ethApi
,
js
.
re
.
ToVal
,
js
.
re
)
...
...
cmd/ethtest/main.go
View file @
f2f65c1a
...
@@ -33,12 +33,12 @@ import (
...
@@ -33,12 +33,12 @@ import (
"strings"
"strings"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/tests/helper"
"github.com/ethereum/go-ethereum/tests/helper"
"github.com/ethereum/go-ethereum/core/vm"
)
)
type
Log
struct
{
type
Log
struct
{
...
@@ -80,8 +80,7 @@ func StateObjectFromAccount(db common.Database, addr string, account Account) *s
...
@@ -80,8 +80,7 @@ func StateObjectFromAccount(db common.Database, addr string, account Account) *s
}
}
type
VmTest
struct
{
type
VmTest
struct
{
Callcreates
interface
{}
Callcreates
interface
{}
//Env map[string]string
Env
Env
Env
Env
Exec
map
[
string
]
string
Exec
map
[
string
]
string
Transaction
map
[
string
]
string
Transaction
map
[
string
]
string
...
@@ -219,7 +218,7 @@ func RunVmTest(r io.Reader) (failed int) {
...
@@ -219,7 +218,7 @@ func RunVmTest(r io.Reader) (failed int) {
}
}
func
main
()
{
func
main
()
{
//
helper.Logger.SetLogLevel(5)
helper
.
Logger
.
SetLogLevel
(
5
)
vm
.
Debug
=
true
vm
.
Debug
=
true
if
len
(
os
.
Args
)
>
1
{
if
len
(
os
.
Args
)
>
1
{
...
...
eth/backend.go
View file @
f2f65c1a
...
@@ -13,6 +13,7 @@ import (
...
@@ -13,6 +13,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/event"
...
@@ -21,7 +22,6 @@ import (
...
@@ -21,7 +22,6 @@ import (
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/nat"
"github.com/ethereum/go-ethereum/p2p/nat"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/whisper"
"github.com/ethereum/go-ethereum/whisper"
)
)
...
@@ -141,8 +141,8 @@ type Ethereum struct {
...
@@ -141,8 +141,8 @@ type Ethereum struct {
Mining
bool
Mining
bool
DataDir
string
DataDir
string
version
string
version
string
P
rotocolVersion
int
p
rotocolVersion
int
N
etworkId
int
n
etworkId
int
}
}
func
New
(
config
*
Config
)
(
*
Ethereum
,
error
)
{
func
New
(
config
*
Config
)
(
*
Ethereum
,
error
)
{
...
@@ -177,15 +177,16 @@ func New(config *Config) (*Ethereum, error) {
...
@@ -177,15 +177,16 @@ func New(config *Config) (*Ethereum, error) {
servlogger
.
Infof
(
"Protocol Version: %v, Network Id: %v"
,
config
.
ProtocolVersion
,
config
.
NetworkId
)
servlogger
.
Infof
(
"Protocol Version: %v, Network Id: %v"
,
config
.
ProtocolVersion
,
config
.
NetworkId
)
eth
:=
&
Ethereum
{
eth
:=
&
Ethereum
{
shutdownChan
:
make
(
chan
bool
),
shutdownChan
:
make
(
chan
bool
),
blockDb
:
blockDb
,
blockDb
:
blockDb
,
stateDb
:
stateDb
,
stateDb
:
stateDb
,
extraDb
:
extraDb
,
extraDb
:
extraDb
,
eventMux
:
&
event
.
TypeMux
{},
eventMux
:
&
event
.
TypeMux
{},
// logger: servlogsystem,
accountManager
:
config
.
AccountManager
,
accountManager
:
config
.
AccountManager
,
DataDir
:
config
.
DataDir
,
DataDir
:
config
.
DataDir
,
version
:
config
.
Name
,
// TODO should separate from Name
version
:
config
.
Name
,
// TODO should separate from Name
protocolVersion
:
config
.
ProtocolVersion
,
networkId
:
config
.
NetworkId
,
}
}
eth
.
chainManager
=
core
.
NewChainManager
(
blockDb
,
stateDb
,
eth
.
EventMux
())
eth
.
chainManager
=
core
.
NewChainManager
(
blockDb
,
stateDb
,
eth
.
EventMux
())
...
@@ -324,6 +325,8 @@ func (s *Ethereum) PeerCount() int { return s.net.PeerCoun
...
@@ -324,6 +325,8 @@ func (s *Ethereum) PeerCount() int { return s.net.PeerCoun
func
(
s
*
Ethereum
)
Peers
()
[]
*
p2p
.
Peer
{
return
s
.
net
.
Peers
()
}
func
(
s
*
Ethereum
)
Peers
()
[]
*
p2p
.
Peer
{
return
s
.
net
.
Peers
()
}
func
(
s
*
Ethereum
)
MaxPeers
()
int
{
return
s
.
net
.
MaxPeers
}
func
(
s
*
Ethereum
)
MaxPeers
()
int
{
return
s
.
net
.
MaxPeers
}
func
(
s
*
Ethereum
)
Version
()
string
{
return
s
.
version
}
func
(
s
*
Ethereum
)
Version
()
string
{
return
s
.
version
}
func
(
s
*
Ethereum
)
ProtocolVersion
()
int
{
return
s
.
protocolVersion
}
func
(
s
*
Ethereum
)
NetworkId
()
int
{
return
s
.
networkId
}
// Start the ethereum
// Start the ethereum
func
(
s
*
Ethereum
)
Start
()
error
{
func
(
s
*
Ethereum
)
Start
()
error
{
...
...
logger/logsystem.go
View file @
f2f65c1a
...
@@ -14,17 +14,17 @@ type LogSystem interface {
...
@@ -14,17 +14,17 @@ type LogSystem interface {
// NewStdLogSystem creates a LogSystem that prints to the given writer.
// NewStdLogSystem creates a LogSystem that prints to the given writer.
// The flag values are defined package log.
// The flag values are defined package log.
func
NewStdLogSystem
(
writer
io
.
Writer
,
flags
int
,
level
LogLevel
)
LogSystem
{
func
NewStdLogSystem
(
writer
io
.
Writer
,
flags
int
,
level
LogLevel
)
*
Std
LogSystem
{
logger
:=
log
.
New
(
writer
,
""
,
flags
)
logger
:=
log
.
New
(
writer
,
""
,
flags
)
return
&
s
tdLogSystem
{
logger
,
uint32
(
level
)}
return
&
S
tdLogSystem
{
logger
,
uint32
(
level
)}
}
}
type
s
tdLogSystem
struct
{
type
S
tdLogSystem
struct
{
logger
*
log
.
Logger
logger
*
log
.
Logger
level
uint32
level
uint32
}
}
func
(
t
*
s
tdLogSystem
)
LogPrint
(
msg
LogMsg
)
{
func
(
t
*
S
tdLogSystem
)
LogPrint
(
msg
LogMsg
)
{
stdmsg
,
ok
:=
msg
.
(
stdMsg
)
stdmsg
,
ok
:=
msg
.
(
stdMsg
)
if
ok
{
if
ok
{
if
t
.
GetLogLevel
()
>=
stdmsg
.
Level
()
{
if
t
.
GetLogLevel
()
>=
stdmsg
.
Level
()
{
...
@@ -33,11 +33,11 @@ func (t *stdLogSystem) LogPrint(msg LogMsg) {
...
@@ -33,11 +33,11 @@ func (t *stdLogSystem) LogPrint(msg LogMsg) {
}
}
}
}
func
(
t
*
s
tdLogSystem
)
SetLogLevel
(
i
LogLevel
)
{
func
(
t
*
S
tdLogSystem
)
SetLogLevel
(
i
LogLevel
)
{
atomic
.
StoreUint32
(
&
t
.
level
,
uint32
(
i
))
atomic
.
StoreUint32
(
&
t
.
level
,
uint32
(
i
))
}
}
func
(
t
*
s
tdLogSystem
)
GetLogLevel
()
LogLevel
{
func
(
t
*
S
tdLogSystem
)
GetLogLevel
()
LogLevel
{
return
LogLevel
(
atomic
.
LoadUint32
(
&
t
.
level
))
return
LogLevel
(
atomic
.
LoadUint32
(
&
t
.
level
))
}
}
...
...
p2p/testlog_test.go
View file @
f2f65c1a
...
@@ -15,11 +15,8 @@ func testlog(t *testing.T) testLogger {
...
@@ -15,11 +15,8 @@ func testlog(t *testing.T) testLogger {
return
l
return
l
}
}
func
(
testLogger
)
GetLogLevel
()
logger
.
LogLevel
{
return
logger
.
DebugDetailLevel
}
func
(
l
testLogger
)
LogPrint
(
msg
logger
.
LogMsg
)
{
func
(
testLogger
)
SetLogLevel
(
logger
.
LogLevel
)
{}
l
.
t
.
Logf
(
"%s"
,
msg
.
String
())
func
(
l
testLogger
)
LogPrint
(
level
logger
.
LogLevel
,
msg
string
)
{
l
.
t
.
Logf
(
"%s"
,
msg
)
}
}
func
(
testLogger
)
detach
()
{
func
(
testLogger
)
detach
()
{
...
...
rpc/api.go
View file @
f2f65c1a
...
@@ -44,6 +44,10 @@ func (api *EthereumApi) xethAtStateNum(num int64) *xeth.XEth {
...
@@ -44,6 +44,10 @@ func (api *EthereumApi) xethAtStateNum(num int64) *xeth.XEth {
return
api
.
xeth
()
.
AtStateNum
(
num
)
return
api
.
xeth
()
.
AtStateNum
(
num
)
}
}
func
(
api
*
EthereumApi
)
Close
()
{
api
.
db
.
Close
()
}
func
(
api
*
EthereumApi
)
GetRequestReply
(
req
*
RpcRequest
,
reply
*
interface
{})
error
{
func
(
api
*
EthereumApi
)
GetRequestReply
(
req
*
RpcRequest
,
reply
*
interface
{})
error
{
// Spec at https://github.com/ethereum/wiki/wiki/Generic-JSON-RPC
// Spec at https://github.com/ethereum/wiki/wiki/Generic-JSON-RPC
rpclogger
.
Debugf
(
"%s %s"
,
req
.
Method
,
req
.
Params
)
rpclogger
.
Debugf
(
"%s %s"
,
req
.
Method
,
req
.
Params
)
...
@@ -58,7 +62,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
...
@@ -58,7 +62,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
case
"web3_clientVersion"
:
case
"web3_clientVersion"
:
*
reply
=
api
.
xeth
()
.
Backend
()
.
Version
()
*
reply
=
api
.
xeth
()
.
Backend
()
.
Version
()
case
"net_version"
:
case
"net_version"
:
return
NewNotImplementedError
(
req
.
Method
)
*
reply
=
string
(
api
.
xeth
()
.
Backend
()
.
ProtocolVersion
()
)
case
"net_listening"
:
case
"net_listening"
:
*
reply
=
api
.
xeth
()
.
IsListening
()
*
reply
=
api
.
xeth
()
.
IsListening
()
case
"net_peerCount"
:
case
"net_peerCount"
:
...
...
rpc/args.go
View file @
f2f65c1a
...
@@ -467,7 +467,7 @@ func (args *BlockFilterArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -467,7 +467,7 @@ func (args *BlockFilterArgs) UnmarshalJSON(b []byte) (err error) {
switch
fromstr
{
switch
fromstr
{
case
"latest"
:
case
"latest"
:
args
.
Earliest
=
0
args
.
Earliest
=
-
1
default
:
default
:
args
.
Earliest
=
int64
(
common
.
Big
(
obj
[
0
]
.
FromBlock
.
(
string
))
.
Int64
())
args
.
Earliest
=
int64
(
common
.
Big
(
obj
[
0
]
.
FromBlock
.
(
string
))
.
Int64
())
}
}
...
@@ -479,9 +479,9 @@ func (args *BlockFilterArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -479,9 +479,9 @@ func (args *BlockFilterArgs) UnmarshalJSON(b []byte) (err error) {
switch
tostr
{
switch
tostr
{
case
"latest"
:
case
"latest"
:
args
.
Latest
=
0
case
"pending"
:
args
.
Latest
=
-
1
args
.
Latest
=
-
1
case
"pending"
:
args
.
Latest
=
-
2
default
:
default
:
args
.
Latest
=
int64
(
common
.
Big
(
obj
[
0
]
.
ToBlock
.
(
string
))
.
Int64
())
args
.
Latest
=
int64
(
common
.
Big
(
obj
[
0
]
.
ToBlock
.
(
string
))
.
Int64
())
}
}
...
@@ -775,8 +775,7 @@ func (args *SubmitWorkArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -775,8 +775,7 @@ func (args *SubmitWorkArgs) UnmarshalJSON(b []byte) (err error) {
return
NewDecodeParamError
(
"Nonce is not a string"
)
return
NewDecodeParamError
(
"Nonce is not a string"
)
}
}
args
.
Nonce
=
common
.
BytesToNumber
(
common
.
Hex2Bytes
(
objstr
))
args
.
Nonce
=
common
.
String2Big
(
objstr
)
.
Uint64
()
if
objstr
,
ok
=
obj
[
1
]
.
(
string
);
!
ok
{
if
objstr
,
ok
=
obj
[
1
]
.
(
string
);
!
ok
{
return
NewDecodeParamError
(
"Header is not a string"
)
return
NewDecodeParamError
(
"Header is not a string"
)
}
}
...
...
rpc/args_test.go
View file @
f2f65c1a
...
@@ -5,6 +5,8 @@ import (
...
@@ -5,6 +5,8 @@ import (
"encoding/json"
"encoding/json"
"math/big"
"math/big"
"testing"
"testing"
"github.com/ethereum/go-ethereum/common"
)
)
func
TestSha3
(
t
*
testing
.
T
)
{
func
TestSha3
(
t
*
testing
.
T
)
{
...
@@ -440,8 +442,8 @@ func TestBlockFilterArgsWords(t *testing.T) {
...
@@ -440,8 +442,8 @@ func TestBlockFilterArgsWords(t *testing.T) {
"toBlock": "pending"
"toBlock": "pending"
}]`
}]`
expected
:=
new
(
BlockFilterArgs
)
expected
:=
new
(
BlockFilterArgs
)
expected
.
Earliest
=
0
expected
.
Earliest
=
-
1
expected
.
Latest
=
-
1
expected
.
Latest
=
-
2
args
:=
new
(
BlockFilterArgs
)
args
:=
new
(
BlockFilterArgs
)
if
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
);
err
!=
nil
{
...
@@ -651,6 +653,10 @@ func TestFilterStringArgs(t *testing.T) {
...
@@ -651,6 +653,10 @@ func TestFilterStringArgs(t *testing.T) {
t
.
Error
(
err
)
t
.
Error
(
err
)
}
}
if
err
:=
args
.
requirements
();
err
!=
nil
{
t
.
Error
(
err
)
}
if
expected
.
Word
!=
args
.
Word
{
if
expected
.
Word
!=
args
.
Word
{
t
.
Errorf
(
"Word shoud be %#v but is %#v"
,
expected
.
Word
,
args
.
Word
)
t
.
Errorf
(
"Word shoud be %#v but is %#v"
,
expected
.
Word
,
args
.
Word
)
}
}
...
@@ -720,3 +726,28 @@ func TestHashIndexArgs(t *testing.T) {
...
@@ -720,3 +726,28 @@ func TestHashIndexArgs(t *testing.T) {
t
.
Errorf
(
"Index shoud be %#v but is %#v"
,
expected
.
Index
,
args
.
Index
)
t
.
Errorf
(
"Index shoud be %#v but is %#v"
,
expected
.
Index
,
args
.
Index
)
}
}
}
}
func
TestSubmitWorkArgs
(
t
*
testing
.
T
)
{
input
:=
`["0x0000000000000001", "0x1234567890abcdef1234567890abcdef", "0xD1GE5700000000000000000000000000"]`
expected
:=
new
(
SubmitWorkArgs
)
expected
.
Nonce
=
1
expected
.
Header
=
common
.
HexToHash
(
"0x1234567890abcdef1234567890abcdef"
)
expected
.
Digest
=
common
.
HexToHash
(
"0xD1GE5700000000000000000000000000"
)
args
:=
new
(
SubmitWorkArgs
)
if
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
);
err
!=
nil
{
t
.
Error
(
err
)
}
if
expected
.
Nonce
!=
args
.
Nonce
{
t
.
Errorf
(
"Nonce shoud be %d but is %d"
,
expected
.
Nonce
,
args
.
Nonce
)
}
if
expected
.
Header
!=
args
.
Header
{
t
.
Errorf
(
"Header shoud be %#v but is %#v"
,
expected
.
Header
,
args
.
Header
)
}
if
expected
.
Digest
!=
args
.
Digest
{
t
.
Errorf
(
"Digest shoud be %#v but is %#v"
,
expected
.
Digest
,
args
.
Digest
)
}
}
tests/helper/init.go
View file @
f2f65c1a
...
@@ -7,7 +7,7 @@ import (
...
@@ -7,7 +7,7 @@ import (
logpkg
"github.com/ethereum/go-ethereum/logger"
logpkg
"github.com/ethereum/go-ethereum/logger"
)
)
var
Logger
logpkg
.
LogSystem
var
Logger
*
logpkg
.
Std
LogSystem
var
Log
=
logpkg
.
NewLogger
(
"TEST"
)
var
Log
=
logpkg
.
NewLogger
(
"TEST"
)
func
init
()
{
func
init
()
{
...
...
xeth/xeth.go
View file @
f2f65c1a
...
@@ -12,6 +12,7 @@ import (
...
@@ -12,6 +12,7 @@ import (
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/event"
...
@@ -19,7 +20,6 @@ import (
...
@@ -19,7 +20,6 @@ import (
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/miner"
"github.com/ethereum/go-ethereum/miner"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/whisper"
"github.com/ethereum/go-ethereum/whisper"
)
)
...
@@ -50,6 +50,8 @@ type Backend interface {
...
@@ -50,6 +50,8 @@ type Backend interface {
StartMining
()
error
StartMining
()
error
StopMining
()
StopMining
()
Version
()
string
Version
()
string
ProtocolVersion
()
int
NetworkId
()
int
}
}
// Frontend should be implemented by users of XEth. Its methods are
// Frontend should be implemented by users of XEth. Its methods are
...
...
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