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
f1ba1df1
Commit
f1ba1df1
authored
Feb 08, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added key address and key generation
parent
827f341c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
26 deletions
+70
-26
README.md
README.md
+1
-4
config.go
config.go
+26
-0
dev_console.go
dev_console.go
+2
-1
ethereum.go
ethereum.go
+41
-21
No files found.
README.md
View file @
f1ba1df1
...
...
@@ -3,7 +3,7 @@ Ethereum
[

](https://travis-ci.org/ethereum/go-ethereum)
Ethereum Go developer client (c)
[
0255c7881
](
https://github.com/ethereum/go-ethereum#copy
)
Ethereum Go developer client (c)
Jeffrey Wilcke
A fair warning; Ethereum is not yet to be used in production. There's no
test-net and you aren't mining real blocks (just one which is the genesis block).
...
...
@@ -95,6 +95,3 @@ expect you to write tests for me so I don't have to test your code
manually. (If you want to contribute by just writing tests that's fine
too!)
### Copy
69bce990a619e747b4f57483724b0e8a1732bb3b44ccf70b0dd6abd272af94550fc9d8b21232d33ebf30d38a148612f68e936094b4daeb9ea7174088a439070401 0255c78815d4f056f84c96de438ed9e38c69c0f8af24f5032248be5a79fe9071c3
config.go
0 → 100644
View file @
f1ba1df1
package
main
import
(
"flag"
)
var
StartConsole
bool
var
StartMining
bool
var
UseUPnP
bool
var
OutboundPort
string
var
ShowGenesis
bool
var
AddPeer
string
var
MaxPeer
int
var
GenAddr
bool
func
Init
()
{
flag
.
BoolVar
(
&
StartConsole
,
"c"
,
false
,
"debug and testing console"
)
flag
.
BoolVar
(
&
StartMining
,
"m"
,
false
,
"start dagger mining"
)
flag
.
BoolVar
(
&
ShowGenesis
,
"g"
,
false
,
"prints genesis header and exits"
)
flag
.
BoolVar
(
&
UseUPnP
,
"upnp"
,
false
,
"enable UPnP support"
)
flag
.
BoolVar
(
&
GenAddr
,
"genaddr"
,
false
,
"create a new priv/pub key"
)
flag
.
StringVar
(
&
OutboundPort
,
"p"
,
"30303"
,
"listening port"
)
flag
.
IntVar
(
&
MaxPeer
,
"x"
,
5
,
"maximum desired peers"
)
flag
.
Parse
()
}
dev_console.go
View file @
f1ba1df1
...
...
@@ -149,7 +149,8 @@ func (i *Console) ParseInput(input string) bool {
fmt
.
Println
(
"recipient err:"
,
err
)
}
else
{
tx
:=
ethchain
.
NewTransaction
(
recipient
,
ethutil
.
Big
(
tokens
[
2
]),
[]
string
{
""
})
tx
.
Sign
([]
byte
(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
))
privKey
,
_
:=
ethutil
.
Config
.
Db
.
Get
([]
byte
(
"KeyRing"
))
tx
.
Sign
(
privKey
)
fmt
.
Printf
(
"%x
\n
"
,
tx
.
Hash
())
i
.
ethereum
.
TxPool
.
QueueTransaction
(
tx
)
}
...
...
ethereum.go
View file @
f1ba1df1
...
...
@@ -2,12 +2,11 @@ package main
import
(
"encoding/hex"
"flag"
"fmt"
"github.com/ethereum/eth-go"
"github.com/ethereum/ethchain-go"
"github.com/ethereum/ethutil-go"
_
"github.com/ethereum/ethwire
-go"
"github.com/obscuren/secp256k1
-go"
"log"
"os"
"os/signal"
...
...
@@ -16,22 +15,6 @@ import (
const
Debug
=
true
var
StartConsole
bool
var
StartMining
bool
var
UseUPnP
bool
var
OutboundPort
string
var
ShowGenesis
bool
func
Init
()
{
flag
.
BoolVar
(
&
StartConsole
,
"c"
,
false
,
"debug and testing console"
)
flag
.
BoolVar
(
&
StartMining
,
"m"
,
false
,
"start dagger mining"
)
flag
.
BoolVar
(
&
ShowGenesis
,
"g"
,
false
,
"prints genesis header and exits"
)
flag
.
BoolVar
(
&
UseUPnP
,
"upnp"
,
false
,
"enable UPnP support"
)
flag
.
StringVar
(
&
OutboundPort
,
"port"
,
"30303"
,
"listening port"
)
flag
.
Parse
()
}
// Register interrupt handlers so we can stop the ethereum
func
RegisterInterupts
(
s
*
eth
.
Ethereum
)
{
// Buffered chan of one is enough
...
...
@@ -47,6 +30,17 @@ func RegisterInterupts(s *eth.Ethereum) {
}()
}
func
CreateKeyPair
(
force
bool
)
{
data
,
_
:=
ethutil
.
Config
.
Db
.
Get
([]
byte
(
"KeyRing"
))
if
len
(
data
)
==
0
||
force
{
log
.
Println
(
"Generating new address and keypair"
)
pub
,
prv
:=
secp256k1
.
GenerateKeyPair
()
ethutil
.
Config
.
Db
.
Put
([]
byte
(
"KeyRing"
),
prv
)
}
}
func
main
()
{
runtime
.
GOMAXPROCS
(
runtime
.
NumCPU
())
Init
()
...
...
@@ -57,10 +51,31 @@ func main() {
// Instantiated a eth stack
ethereum
,
err
:=
eth
.
New
(
eth
.
CapDefault
,
UseUPnP
)
if
err
!=
nil
{
log
.
Println
(
err
)
log
.
Println
(
"eth start err:"
,
err
)
return
}
if
GenAddr
{
fmt
.
Println
(
"This action overwrites your old private key. Are you sure? (y/n)"
)
var
r
string
fmt
.
Scanln
(
&
r
)
for
;
;
fmt
.
Scanln
(
&
r
)
{
if
r
==
"n"
||
r
==
"y"
{
break
}
else
{
fmt
.
Println
(
"Yes or no?"
,
r
)
}
}
if
r
==
"y"
{
CreateKeyPair
(
true
)
}
os
.
Exit
(
0
)
}
else
{
CreateKeyPair
(
false
)
}
if
ShowGenesis
{
fmt
.
Println
(
ethereum
.
BlockManager
.
BlockChain
()
.
Genesis
())
os
.
Exit
(
0
)
...
...
@@ -68,6 +83,9 @@ func main() {
log
.
Printf
(
"Starting Ethereum v%s
\n
"
,
ethutil
.
Config
.
Ver
)
// Set the max peers
ethereum
.
MaxPeers
=
MaxPeer
if
StartConsole
{
err
:=
os
.
Mkdir
(
ethutil
.
Config
.
ExecPath
,
os
.
ModePerm
)
// Error is OK if the error is ErrExist
...
...
@@ -97,14 +115,16 @@ func main() {
block
:=
ethereum
.
BlockManager
.
BlockChain
()
.
NewBlock
(
addr
,
txs
)
// Apply all transactions to the block
ethereum
.
BlockManager
.
ApplyTransactions
(
block
,
block
.
Transactions
())
ethereum
.
BlockManager
.
AccumelateRewards
(
block
,
block
)
// Search the nonce
block
.
Nonce
=
pow
.
Search
(
block
)
err
:=
ethereum
.
BlockManager
.
ProcessBlock
(
block
)
if
err
!=
nil
{
log
.
Println
(
err
)
}
else
{
//ethereum.Broadcast(ethwire.MsgBlockTy, []interface{}{block.RlpValue().Value})
log
.
Println
(
"
\n
+++++++ MINED BLK +++++++
\n
"
,
block
.
String
())
log
.
Println
(
"
\n
+++++++ MINED BLK +++++++
\n
"
,
ethereum
.
BlockManager
.
BlockChain
()
.
CurrentBlock
)
}
}
}()
...
...
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