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
8ea7e21f
Commit
8ea7e21f
authored
Mar 17, 2014
by
Maran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge
parent
3274e0a2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
132 additions
and
33 deletions
+132
-33
README.md
README.md
+2
-2
dagger.go
ethchain/dagger.go
+18
-5
keypair.go
ethchain/keypair.go
+74
-0
state_manager.go
ethchain/state_manager.go
+0
-1
ethereum.go
ethereum.go
+38
-13
trie.go
ethutil/trie.go
+0
-12
No files found.
README.md
View file @
8ea7e21f
...
...
@@ -6,7 +6,7 @@ Ethereum
Ethereum Go Development package (C) Jeffrey Wilcke
Ethereum is currently in its testing phase. The current state is "Proof
of Concept
2". For build instructions see the
[
Wiki
](
https://github.com/ethereum/go-ethereum/wiki/Building-Edge
)
.
of Concept
3". For build instructions see the
[
Wiki
](
https://github.com/ethereum/go-ethereum/wiki/Building-Ethereum(Go
)
).
Ethereum Go is split up in several sub packages Please refer to each
individual package for more information.
...
...
@@ -35,7 +35,7 @@ get a node and connectivity going.
Build
=======
This is the Developer package. For the
development
client please see
This is the Developer package. For the
Ethereal
client please see
[
Ethereum(G)
](
https://github.com/ethereum/go-ethereum
)
.
`go get -u github.com/ethereum/eth-go`
...
...
ethchain/dagger.go
View file @
8ea7e21f
...
...
@@ -11,7 +11,7 @@ import (
)
type
PoW
interface
{
Search
(
block
*
Block
,
breakChan
chan
bool
)
[]
byte
Search
(
block
*
Block
,
minerChan
chan
ethutil
.
React
)
[]
byte
Verify
(
hash
[]
byte
,
diff
*
big
.
Int
,
nonce
[]
byte
)
bool
}
...
...
@@ -19,19 +19,32 @@ type EasyPow struct {
hash
*
big
.
Int
}
func
(
pow
*
EasyPow
)
Search
(
block
*
Block
,
breakChan
chan
bool
)
[]
byte
{
func
(
pow
*
EasyPow
)
Search
(
block
*
Block
,
minerChan
chan
ethutil
.
React
)
[]
byte
{
r
:=
rand
.
New
(
rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
hash
:=
block
.
HashNoNonce
()
diff
:=
block
.
Difficulty
i
:=
int64
(
0
)
start
:=
time
.
Now
()
.
UnixNano
()
for
{
select
{
case
shouldbreak
:=
<-
breakChan
:
if
shouldbreak
{
log
.
Println
(
"Got signal: Breaking out mining."
)
case
chanMessage
:=
<-
minerChan
:
if
_
,
ok
:=
chanMessage
.
Resource
.
(
*
Block
);
ok
{
log
.
Println
(
"BREAKING OUT: BLOCK"
)
return
nil
}
if
_
,
ok
:=
chanMessage
.
Resource
.
(
*
Transaction
);
ok
{
log
.
Println
(
"BREAKING OUT: TX"
)
return
nil
}
default
:
i
++
if
i
%
1234567
==
0
{
elapsed
:=
time
.
Now
()
.
UnixNano
()
-
start
hashes
:=
((
float64
(
1e9
)
/
float64
(
elapsed
))
*
float64
(
i
))
/
1000
log
.
Println
(
"Hashing @"
,
int64
(
hashes
),
"khash"
)
}
sha
:=
ethutil
.
Sha3Bin
(
big
.
NewInt
(
r
.
Int63
())
.
Bytes
())
if
pow
.
Verify
(
hash
,
diff
,
sha
)
{
return
sha
...
...
ethchain/keypair.go
0 → 100644
View file @
8ea7e21f
package
ethchain
import
(
"github.com/ethereum/eth-go/ethutil"
"math/big"
)
type
KeyPair
struct
{
PrivateKey
[]
byte
PublicKey
[]
byte
// The associated account
account
*
Account
state
*
State
}
func
NewKeyPairFromValue
(
val
*
ethutil
.
Value
)
*
KeyPair
{
keyPair
:=
&
KeyPair
{
PrivateKey
:
val
.
Get
(
0
)
.
Bytes
(),
PublicKey
:
val
.
Get
(
1
)
.
Bytes
()}
return
keyPair
}
func
(
k
*
KeyPair
)
Address
()
[]
byte
{
return
ethutil
.
Sha3Bin
(
k
.
PublicKey
[
1
:
])[
12
:
]
}
func
(
k
*
KeyPair
)
Account
()
*
Account
{
if
k
.
account
==
nil
{
k
.
account
=
k
.
state
.
GetAccount
(
k
.
Address
())
}
return
k
.
account
}
// Create transaction, creates a new and signed transaction, ready for processing
func
(
k
*
KeyPair
)
CreateTx
(
receiver
[]
byte
,
value
*
big
.
Int
,
data
[]
string
)
*
Transaction
{
tx
:=
NewTransaction
(
receiver
,
value
,
data
)
tx
.
Nonce
=
k
.
account
.
Nonce
// Sign the transaction with the private key in this key chain
tx
.
Sign
(
k
.
PrivateKey
)
return
tx
}
func
(
k
*
KeyPair
)
RlpEncode
()
[]
byte
{
return
ethutil
.
EmptyValue
()
.
Append
(
k
.
PrivateKey
)
.
Append
(
k
.
PublicKey
)
.
Encode
()
}
type
KeyRing
struct
{
keys
[]
*
KeyPair
}
func
(
k
*
KeyRing
)
Add
(
pair
*
KeyPair
)
{
k
.
keys
=
append
(
k
.
keys
,
pair
)
}
// The public "singleton" keyring
var
keyRing
*
KeyRing
func
GetKeyRing
(
state
*
State
)
*
KeyRing
{
if
keyRing
==
nil
{
keyRing
=
&
KeyRing
{}
data
,
_
:=
ethutil
.
Config
.
Db
.
Get
([]
byte
(
"KeyRing"
))
it
:=
ethutil
.
NewValueFromBytes
(
data
)
.
NewIterator
()
for
it
.
Next
()
{
v
:=
it
.
Value
()
keyRing
.
Add
(
NewKeyPairFromValue
(
v
))
}
}
return
keyRing
}
ethchain/state_manager.go
View file @
8ea7e21f
...
...
@@ -22,7 +22,6 @@ type EthManager interface {
Reactor
()
*
ethutil
.
ReactorEngine
}
// TODO rename to state manager
type
StateManager
struct
{
// Mutex for locking the block processor. Blocks can only be handled one at a time
mutex
sync
.
Mutex
...
...
ethereum.go
View file @
8ea7e21f
...
...
@@ -271,20 +271,45 @@ func (s *Ethereum) Start() {
if
ethutil
.
Config
.
Seed
{
ethutil
.
Config
.
Log
.
Debugln
(
"Seeding"
)
// Testnet seed bootstrapping
resp
,
err
:=
http
.
Get
(
"https://www.ethereum.org/servers.poc3.txt"
)
if
err
!=
nil
{
log
.
Println
(
"Fetching seed failed:"
,
err
)
return
}
defer
resp
.
Body
.
Close
()
body
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
if
err
!=
nil
{
log
.
Println
(
"Reading seed failed:"
,
err
)
return
}
// DNS Bootstrapping
_
,
nodes
,
err
:=
net
.
LookupSRV
(
"eth"
,
"tcp"
,
"ethereum.org"
)
if
err
==
nil
{
peers
:=
[]
string
{}
// Iterate SRV nodes
for
_
,
n
:=
range
nodes
{
target
:=
n
.
Target
port
:=
strconv
.
Itoa
(
int
(
n
.
Port
))
// Resolve target to ip (Go returns list, so may resolve to multiple ips?)
addr
,
err
:=
net
.
LookupHost
(
target
)
if
err
==
nil
{
for
_
,
a
:=
range
addr
{
// Build string out of SRV port and Resolved IP
peer
:=
net
.
JoinHostPort
(
a
,
port
)
log
.
Println
(
"Found DNS Bootstrap Peer:"
,
peer
)
peers
=
append
(
peers
,
peer
)
}
}
else
{
log
.
Println
(
"Couldn't resolve :"
,
target
)
}
}
// Connect to Peer list
s
.
ProcessPeerList
(
peers
)
}
else
{
// Fallback to servers.poc3.txt
resp
,
err
:=
http
.
Get
(
"http://www.ethereum.org/servers.poc3.txt"
)
if
err
!=
nil
{
log
.
Println
(
"Fetching seed failed:"
,
err
)
return
}
defer
resp
.
Body
.
Close
()
body
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
if
err
!=
nil
{
log
.
Println
(
"Reading seed failed:"
,
err
)
return
}
s
.
ConnectToPeer
(
string
(
body
))
s
.
ConnectToPeer
(
string
(
body
))
}
}
}
...
...
ethutil/trie.go
View file @
8ea7e21f
...
...
@@ -219,18 +219,6 @@ func (t *Trie) UpdateState(node interface{}, key []int, value string) interface{
}
func
(
t
*
Trie
)
Put
(
node
interface
{})
interface
{}
{
/*
enc := Encode(node)
if len(enc) >= 32 {
var sha []byte
sha = Sha3Bin(enc)
//t.db.Put([]byte(sha), enc)
return sha
}
return node
*/
/*
TODO?
c := Conv(t.Root)
...
...
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