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
f111fc06
Commit
f111fc06
authored
Dec 15, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP
parent
1d959cb0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
47 deletions
+18
-47
backend.go
eth/backend.go
+10
-43
pow.go
pow/ezp/pow.go
+8
-4
No files found.
eth/backend.go
View file @
f111fc06
...
@@ -3,7 +3,6 @@ package eth
...
@@ -3,7 +3,6 @@ package eth
import
(
import
(
"encoding/json"
"encoding/json"
"net"
"net"
"path"
"sync"
"sync"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core"
...
@@ -32,7 +31,6 @@ type Ethereum struct {
...
@@ -32,7 +31,6 @@ type Ethereum struct {
db
ethutil
.
Database
db
ethutil
.
Database
// State manager for processing new blocks and managing the over all states
// State manager for processing new blocks and managing the over all states
blockManager
*
core
.
BlockManager
blockManager
*
core
.
BlockManager
// The transaction pool. Transaction can be pushed on this pool
// The transaction pool. Transaction can be pushed on this pool
// for later including in the blocks
// for later including in the blocks
txPool
*
core
.
TxPool
txPool
*
core
.
TxPool
...
@@ -43,22 +41,11 @@ type Ethereum struct {
...
@@ -43,22 +41,11 @@ type Ethereum struct {
// Event
// Event
eventMux
*
event
.
TypeMux
eventMux
*
event
.
TypeMux
// Nonce
Nonce
uint64
ListenAddr
string
blacklist
p2p
.
Blacklist
blacklist
p2p
.
Blacklist
server
*
p2p
.
Server
server
*
p2p
.
Server
txSub
event
.
Subscription
txSub
event
.
Subscription
blockSub
event
.
Subscription
blockSub
event
.
Subscription
// Capabilities for outgoing peers
// serverCaps Caps
peersFile
string
Mining
bool
RpcServer
*
rpc
.
JsonRpcServer
RpcServer
*
rpc
.
JsonRpcServer
keyManager
*
crypto
.
KeyManager
keyManager
*
crypto
.
KeyManager
...
@@ -71,6 +58,8 @@ type Ethereum struct {
...
@@ -71,6 +58,8 @@ type Ethereum struct {
filterMu
sync
.
RWMutex
filterMu
sync
.
RWMutex
filterId
int
filterId
int
filters
map
[
int
]
*
core
.
Filter
filters
map
[
int
]
*
core
.
Filter
Mining
bool
}
}
func
New
(
db
ethutil
.
Database
,
identity
p2p
.
ClientIdentity
,
keyManager
*
crypto
.
KeyManager
,
nat
p2p
.
NAT
,
port
string
,
maxPeers
int
)
(
*
Ethereum
,
error
)
{
func
New
(
db
ethutil
.
Database
,
identity
p2p
.
ClientIdentity
,
keyManager
*
crypto
.
KeyManager
,
nat
p2p
.
NAT
,
port
string
,
maxPeers
int
)
(
*
Ethereum
,
error
)
{
...
@@ -78,28 +67,13 @@ func New(db ethutil.Database, identity p2p.ClientIdentity, keyManager *crypto.Ke
...
@@ -78,28 +67,13 @@ func New(db ethutil.Database, identity p2p.ClientIdentity, keyManager *crypto.Ke
saveProtocolVersion
(
db
)
saveProtocolVersion
(
db
)
ethutil
.
Config
.
Db
=
db
ethutil
.
Config
.
Db
=
db
// FIXME:
blacklist
:=
p2p
.
NewBlacklist
()
// Sorry Py person. I must blacklist. you perform badly
blacklist
.
Put
(
ethutil
.
Hex2Bytes
(
"64656330303561383532336435376331616537643864663236623336313863373537353163636634333530626263396330346237336262623931383064393031"
))
peersFile
:=
path
.
Join
(
ethutil
.
Config
.
ExecPath
,
"known_peers.json"
)
nonce
,
_
:=
ethutil
.
RandomUint64
()
listenAddr
:=
":"
+
port
eth
:=
&
Ethereum
{
eth
:=
&
Ethereum
{
shutdownChan
:
make
(
chan
bool
),
shutdownChan
:
make
(
chan
bool
),
quit
:
make
(
chan
bool
),
quit
:
make
(
chan
bool
),
db
:
db
,
db
:
db
,
Nonce
:
nonce
,
// serverCaps: caps,
peersFile
:
peersFile
,
ListenAddr
:
listenAddr
,
keyManager
:
keyManager
,
keyManager
:
keyManager
,
clientIdentity
:
identity
,
clientIdentity
:
identity
,
blacklist
:
blacklist
,
blacklist
:
p2p
.
NewBlocklist
()
,
eventMux
:
&
event
.
TypeMux
{},
eventMux
:
&
event
.
TypeMux
{},
filters
:
make
(
map
[
int
]
*
core
.
Filter
),
filters
:
make
(
map
[
int
]
*
core
.
Filter
),
}
}
...
@@ -111,9 +85,7 @@ func New(db ethutil.Database, identity p2p.ClientIdentity, keyManager *crypto.Ke
...
@@ -111,9 +85,7 @@ func New(db ethutil.Database, identity p2p.ClientIdentity, keyManager *crypto.Ke
hasBlock
:=
eth
.
chainManager
.
HasBlock
hasBlock
:=
eth
.
chainManager
.
HasBlock
insertChain
:=
eth
.
chainManager
.
InsertChain
insertChain
:=
eth
.
chainManager
.
InsertChain
pow
:=
ezp
.
New
()
eth
.
blockPool
=
NewBlockPool
(
hasBlock
,
insertChain
,
ezp
.
Verify
)
verifyPoW
:=
pow
.
Verify
eth
.
blockPool
=
NewBlockPool
(
hasBlock
,
insertChain
,
verifyPoW
)
// Start the tx pool
// Start the tx pool
eth
.
txPool
.
Start
()
eth
.
txPool
.
Start
()
...
@@ -125,7 +97,7 @@ func New(db ethutil.Database, identity p2p.ClientIdentity, keyManager *crypto.Ke
...
@@ -125,7 +97,7 @@ func New(db ethutil.Database, identity p2p.ClientIdentity, keyManager *crypto.Ke
Identity
:
identity
,
Identity
:
identity
,
MaxPeers
:
maxPeers
,
MaxPeers
:
maxPeers
,
Protocols
:
protocols
,
Protocols
:
protocols
,
ListenAddr
:
listenAddr
,
ListenAddr
:
":"
+
port
,
Blacklist
:
blacklist
,
Blacklist
:
blacklist
,
NAT
:
nat
,
NAT
:
nat
,
}
}
...
@@ -171,11 +143,8 @@ func (s *Ethereum) IsMining() bool {
...
@@ -171,11 +143,8 @@ func (s *Ethereum) IsMining() bool {
}
}
func
(
s
*
Ethereum
)
IsListening
()
bool
{
func
(
s
*
Ethereum
)
IsListening
()
bool
{
if
s
.
ListenAddr
==
""
{
// XXX TODO
return
false
return
false
}
else
{
return
true
}
}
}
func
(
s
*
Ethereum
)
PeerCount
()
int
{
func
(
s
*
Ethereum
)
PeerCount
()
int
{
...
@@ -231,8 +200,6 @@ func (s *Ethereum) Stop() {
...
@@ -231,8 +200,6 @@ func (s *Ethereum) Stop() {
// Close the database
// Close the database
defer
s
.
db
.
Close
()
defer
s
.
db
.
Close
()
//
// WritePeers(s.peersFile, s.server.PeerAddresses())
close
(
s
.
quit
)
close
(
s
.
quit
)
s
.
txSub
.
Unsubscribe
()
// quits txBroadcastLoop
s
.
txSub
.
Unsubscribe
()
// quits txBroadcastLoop
...
...
pow/ezp/pow.go
View file @
f111fc06
...
@@ -59,7 +59,7 @@ func (pow *EasyPow) Search(block pow.Block, stop <-chan struct{}) []byte {
...
@@ -59,7 +59,7 @@ func (pow *EasyPow) Search(block pow.Block, stop <-chan struct{}) []byte {
}
}
sha
:=
crypto
.
Sha3
(
big
.
NewInt
(
r
.
Int63
())
.
Bytes
())
sha
:=
crypto
.
Sha3
(
big
.
NewInt
(
r
.
Int63
())
.
Bytes
())
if
pow
.
verify
(
hash
,
diff
,
sha
)
{
if
verify
(
hash
,
diff
,
sha
)
{
return
sha
return
sha
}
}
}
}
...
@@ -72,7 +72,11 @@ func (pow *EasyPow) Search(block pow.Block, stop <-chan struct{}) []byte {
...
@@ -72,7 +72,11 @@ func (pow *EasyPow) Search(block pow.Block, stop <-chan struct{}) []byte {
return
nil
return
nil
}
}
func
(
pow
*
EasyPow
)
verify
(
hash
[]
byte
,
diff
*
big
.
Int
,
nonce
[]
byte
)
bool
{
func
(
pow
*
EasyPow
)
Verify
(
block
pow
.
Block
)
bool
{
return
Verify
(
block
)
}
func
verify
(
hash
[]
byte
,
diff
*
big
.
Int
,
nonce
[]
byte
)
bool
{
sha
:=
sha3
.
NewKeccak256
()
sha
:=
sha3
.
NewKeccak256
()
d
:=
append
(
hash
,
nonce
...
)
d
:=
append
(
hash
,
nonce
...
)
...
@@ -84,6 +88,6 @@ func (pow *EasyPow) verify(hash []byte, diff *big.Int, nonce []byte) bool {
...
@@ -84,6 +88,6 @@ func (pow *EasyPow) verify(hash []byte, diff *big.Int, nonce []byte) bool {
return
res
.
Cmp
(
verification
)
<=
0
return
res
.
Cmp
(
verification
)
<=
0
}
}
func
(
pow
*
EasyPow
)
Verify
(
block
pow
.
Block
)
bool
{
func
Verify
(
block
pow
.
Block
)
bool
{
return
pow
.
verify
(
block
.
HashNoNonce
(),
block
.
Diff
(),
block
.
N
())
return
verify
(
block
.
HashNoNonce
(),
block
.
Diff
(),
block
.
N
())
}
}
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