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
aa1eae67
Commit
aa1eae67
authored
Mar 25, 2015
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #560 from tgerring/xethcleanup
XEth cleanup
parents
7f0c2545
2b93843d
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
153 additions
and
161 deletions
+153
-161
backend.go
eth/backend.go
+21
-18
api.go
rpc/api.go
+8
-4
whisper.go
whisper/whisper.go
+8
-3
frontend.go
xeth/frontend.go
+32
-0
state.go
xeth/state.go
+1
-1
xeth.go
xeth/xeth.go
+83
-135
No files found.
eth/backend.go
View file @
aa1eae67
...
...
@@ -138,11 +138,12 @@ type Ethereum struct {
// logger logger.LogSystem
Mining
bool
DataDir
string
version
string
protocolVersion
int
networkId
int
Mining
bool
DataDir
string
clientVersion
string
ethVersionId
int
netVersionId
int
shhVersionId
int
}
func
New
(
config
*
Config
)
(
*
Ethereum
,
error
)
{
...
...
@@ -177,16 +178,16 @@ func New(config *Config) (*Ethereum, error) {
servlogger
.
Infof
(
"Protocol Version: %v, Network Id: %v"
,
config
.
ProtocolVersion
,
config
.
NetworkId
)
eth
:=
&
Ethereum
{
shutdownChan
:
make
(
chan
bool
),
blockDb
:
blockDb
,
stateDb
:
stateDb
,
extraDb
:
extraDb
,
eventMux
:
&
event
.
TypeMux
{},
accountManager
:
config
.
AccountManager
,
DataDir
:
config
.
DataDir
,
version
:
config
.
Name
,
// TODO should separate from Name
protocolVersion
:
config
.
ProtocolVersion
,
net
workId
:
config
.
NetworkId
,
shutdownChan
:
make
(
chan
bool
),
blockDb
:
blockDb
,
stateDb
:
stateDb
,
extraDb
:
extraDb
,
eventMux
:
&
event
.
TypeMux
{},
accountManager
:
config
.
AccountManager
,
DataDir
:
config
.
DataDir
,
clientVersion
:
config
.
Name
,
// TODO should separate from Name
ethVersionId
:
config
.
ProtocolVersion
,
net
VersionId
:
config
.
NetworkId
,
}
eth
.
chainManager
=
core
.
NewChainManager
(
blockDb
,
stateDb
,
eth
.
EventMux
())
...
...
@@ -195,6 +196,7 @@ func New(config *Config) (*Ethereum, error) {
eth
.
blockProcessor
=
core
.
NewBlockProcessor
(
stateDb
,
extraDb
,
eth
.
pow
,
eth
.
txPool
,
eth
.
chainManager
,
eth
.
EventMux
())
eth
.
chainManager
.
SetProcessor
(
eth
.
blockProcessor
)
eth
.
whisper
=
whisper
.
New
()
eth
.
shhVersionId
=
int
(
eth
.
whisper
.
Version
())
eth
.
miner
=
miner
.
New
(
eth
,
eth
.
pow
,
config
.
MinerThreads
)
hasBlock
:=
eth
.
chainManager
.
HasBlock
...
...
@@ -324,9 +326,10 @@ func (s *Ethereum) IsListening() bool { return true } // Alwa
func
(
s
*
Ethereum
)
PeerCount
()
int
{
return
s
.
net
.
PeerCount
()
}
func
(
s
*
Ethereum
)
Peers
()
[]
*
p2p
.
Peer
{
return
s
.
net
.
Peers
()
}
func
(
s
*
Ethereum
)
MaxPeers
()
int
{
return
s
.
net
.
MaxPeers
}
func
(
s
*
Ethereum
)
Version
()
string
{
return
s
.
version
}
func
(
s
*
Ethereum
)
ProtocolVersion
()
int
{
return
s
.
protocolVersion
}
func
(
s
*
Ethereum
)
NetworkId
()
int
{
return
s
.
networkId
}
func
(
s
*
Ethereum
)
ClientVersion
()
string
{
return
s
.
clientVersion
}
func
(
s
*
Ethereum
)
EthVersion
()
int
{
return
s
.
ethVersionId
}
func
(
s
*
Ethereum
)
NetVersion
()
int
{
return
s
.
netVersionId
}
func
(
s
*
Ethereum
)
ShhVersion
()
int
{
return
s
.
shhVersionId
}
// Start the ethereum
func
(
s
*
Ethereum
)
Start
()
error
{
...
...
rpc/api.go
View file @
aa1eae67
...
...
@@ -49,7 +49,7 @@ func (api *EthereumApi) Close() {
}
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/JSON-RPC
rpclogger
.
Debugf
(
"%s %s"
,
req
.
Method
,
req
.
Params
)
switch
req
.
Method
{
...
...
@@ -60,14 +60,16 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
}
*
reply
=
common
.
ToHex
(
crypto
.
Sha3
(
common
.
FromHex
(
args
.
Data
)))
case
"web3_clientVersion"
:
*
reply
=
api
.
xeth
()
.
Backend
()
.
Version
()
*
reply
=
api
.
xeth
()
.
Client
Version
()
case
"net_version"
:
*
reply
=
string
(
api
.
xeth
()
.
Backend
()
.
ProtocolVersion
()
)
*
reply
=
api
.
xeth
()
.
NetworkVersion
(
)
case
"net_listening"
:
*
reply
=
api
.
xeth
()
.
IsListening
()
case
"net_peerCount"
:
v
:=
api
.
xeth
()
.
PeerCount
()
*
reply
=
common
.
ToHex
(
big
.
NewInt
(
int64
(
v
))
.
Bytes
())
case
"eth_version"
:
*
reply
=
api
.
xeth
()
.
EthVersion
()
case
"eth_coinbase"
:
// TODO handling of empty coinbase due to lack of accounts
res
:=
api
.
xeth
()
.
Coinbase
()
...
...
@@ -84,7 +86,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
case
"eth_accounts"
:
*
reply
=
api
.
xeth
()
.
Accounts
()
case
"eth_blockNumber"
:
v
:=
api
.
xeth
()
.
Backend
()
.
ChainManager
()
.
CurrentBlock
()
.
Number
()
v
:=
api
.
xeth
()
.
CurrentBlock
()
.
Number
()
*
reply
=
common
.
ToHex
(
v
.
Bytes
())
case
"eth_getBalance"
:
args
:=
new
(
GetBalanceArgs
)
...
...
@@ -406,6 +408,8 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
res
,
_
:=
api
.
db
.
Get
([]
byte
(
args
.
Database
+
args
.
Key
))
*
reply
=
common
.
ToHex
(
res
)
case
"shh_version"
:
*
reply
=
api
.
xeth
()
.
WhisperVersion
()
case
"shh_post"
:
args
:=
new
(
WhisperMessageArgs
)
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
...
...
whisper/whisper.go
View file @
aa1eae67
...
...
@@ -16,8 +16,9 @@ import (
)
const
(
statusMsg
=
0x0
envelopesMsg
=
0x01
statusMsg
=
0x0
envelopesMsg
=
0x01
whisperVersion
=
0x02
)
type
MessageEvent
struct
{
...
...
@@ -56,7 +57,7 @@ func New() *Whisper {
// p2p whisper sub protocol handler
whisper
.
protocol
=
p2p
.
Protocol
{
Name
:
"shh"
,
Version
:
2
,
Version
:
uint
(
whisperVersion
)
,
Length
:
2
,
Run
:
whisper
.
msgHandler
,
}
...
...
@@ -64,6 +65,10 @@ func New() *Whisper {
return
whisper
}
func
(
self
*
Whisper
)
Version
()
uint
{
return
self
.
protocol
.
Version
}
func
(
self
*
Whisper
)
Start
()
{
wlogger
.
Infoln
(
"Whisper started"
)
go
self
.
update
()
...
...
xeth/frontend.go
0 → 100644
View file @
aa1eae67
package
xeth
import
(
"github.com/ethereum/go-ethereum/core/types"
)
// Frontend should be implemented by users of XEth. Its methods are
// called whenever XEth makes a decision that requires user input.
type
Frontend
interface
{
// UnlockAccount is called when a transaction needs to be signed
// but the key corresponding to the transaction's sender is
// locked.
//
// It should unlock the account with the given address and return
// true if unlocking succeeded.
UnlockAccount
(
address
[]
byte
)
bool
// This is called for all transactions inititated through
// Transact. It should prompt the user to confirm the transaction
// and return true if the transaction was acknowledged.
//
// ConfirmTransaction is not used for Call transactions
// because they cannot change any state.
ConfirmTransaction
(
tx
*
types
.
Transaction
)
bool
}
// dummyFrontend is a non-interactive frontend that allows all
// transactions but cannot not unlock any keys.
type
dummyFrontend
struct
{}
func
(
dummyFrontend
)
UnlockAccount
([]
byte
)
bool
{
return
false
}
func
(
dummyFrontend
)
ConfirmTransaction
(
*
types
.
Transaction
)
bool
{
return
true
}
xeth/state.go
View file @
aa1eae67
...
...
@@ -29,7 +29,7 @@ func (self *State) SafeGet(addr string) *Object {
func
(
self
*
State
)
safeGet
(
addr
string
)
*
state
.
StateObject
{
object
:=
self
.
state
.
GetStateObject
(
common
.
HexToAddress
(
addr
))
if
object
==
nil
{
object
=
state
.
NewStateObject
(
common
.
HexToAddress
(
addr
),
self
.
xeth
.
eth
.
StateDb
())
object
=
state
.
NewStateObject
(
common
.
HexToAddress
(
addr
),
self
.
xeth
.
backend
.
StateDb
())
}
return
object
...
...
xeth/xeth.go
View file @
aa1eae67
This diff is collapsed.
Click to expand it.
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