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
17b481e3
Commit
17b481e3
authored
9 years ago
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1581 from obscuren/olympic
cmd, core, eth: support for the olympic network
parents
97cdf848
dcdb7059
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
0 deletions
+42
-0
main.go
cmd/geth/main.go
+4
-0
cmd.go
cmd/utils/cmd.go
+17
-0
flags.go
cmd/utils/flags.go
+12
-0
backend.go
eth/backend.go
+9
-0
No files found.
cmd/geth/main.go
View file @
17b481e3
...
...
@@ -280,6 +280,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
utils
.
BootnodesFlag
,
utils
.
DataDirFlag
,
utils
.
BlockchainVersionFlag
,
utils
.
OlympicFlag
,
utils
.
CacheFlag
,
utils
.
JSpathFlag
,
utils
.
ListenPortFlag
,
...
...
@@ -346,6 +347,9 @@ func main() {
func
run
(
ctx
*
cli
.
Context
)
{
utils
.
CheckLegalese
(
ctx
.
GlobalString
(
utils
.
DataDirFlag
.
Name
))
if
ctx
.
GlobalBool
(
utils
.
OlympicFlag
.
Name
)
{
utils
.
InitOlympic
()
}
cfg
:=
utils
.
MakeEthConfig
(
ClientIdentifier
,
nodeNameVersion
,
ctx
)
ethereum
,
err
:=
eth
.
New
(
cfg
)
...
...
This diff is collapsed.
Click to expand it.
cmd/utils/cmd.go
View file @
17b481e3
...
...
@@ -21,6 +21,7 @@ import (
"bufio"
"fmt"
"io"
"math/big"
"os"
"os/signal"
"regexp"
...
...
@@ -32,6 +33,7 @@ import (
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
"github.com/peterh/liner"
)
...
...
@@ -143,6 +145,15 @@ func StartEthereum(ethereum *eth.Ethereum) {
}()
}
func
InitOlympic
()
{
params
.
DurationLimit
=
big
.
NewInt
(
8
)
params
.
GenesisGasLimit
=
big
.
NewInt
(
3141592
)
params
.
MinGasLimit
=
big
.
NewInt
(
125000
)
params
.
MaximumExtraDataSize
=
big
.
NewInt
(
1024
)
NetworkIdFlag
.
Value
=
0
core
.
BlockReward
=
big
.
NewInt
(
1.5e+18
)
}
func
FormatTransactionData
(
data
string
)
[]
byte
{
d
:=
common
.
StringToByteFunc
(
data
,
func
(
s
string
)
(
ret
[]
byte
)
{
slice
:=
regexp
.
MustCompile
(
"
\\
n|
\\
s"
)
.
Split
(
s
,
1000000000
)
...
...
@@ -203,6 +214,11 @@ func ImportChain(chain *core.ChainManager, fn string) error {
}
else
if
err
!=
nil
{
return
fmt
.
Errorf
(
"at block %d: %v"
,
n
,
err
)
}
// don't import first block
if
b
.
NumberU64
()
==
0
{
i
--
continue
}
blocks
[
i
]
=
&
b
n
++
}
...
...
@@ -218,6 +234,7 @@ func ImportChain(chain *core.ChainManager, fn string) error {
batch
,
blocks
[
0
]
.
Hash
()
.
Bytes
()[
:
4
],
blocks
[
i
-
1
]
.
Hash
()
.
Bytes
()[
:
4
])
continue
}
if
_
,
err
:=
chain
.
InsertChain
(
blocks
[
:
i
]);
err
!=
nil
{
return
fmt
.
Errorf
(
"invalid block %d: %v"
,
n
,
err
)
}
...
...
This diff is collapsed.
Click to expand it.
cmd/utils/flags.go
View file @
17b481e3
...
...
@@ -131,6 +131,10 @@ var (
Usage
:
"Megabytes of memory allocated to internal caching"
,
Value
:
0
,
}
OlympicFlag
=
cli
.
BoolFlag
{
Name
:
"olympic"
,
Usage
:
"Use olympic style protocol"
,
}
// miner settings
MinerThreadsFlag
=
cli
.
IntFlag
{
...
...
@@ -402,6 +406,7 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
MaxPeers
:
ctx
.
GlobalInt
(
MaxPeersFlag
.
Name
),
MaxPendingPeers
:
ctx
.
GlobalInt
(
MaxPendingPeersFlag
.
Name
),
Port
:
ctx
.
GlobalString
(
ListenPortFlag
.
Name
),
Olympic
:
ctx
.
GlobalBool
(
OlympicFlag
.
Name
),
NAT
:
MakeNAT
(
ctx
),
NatSpec
:
ctx
.
GlobalBool
(
NatspecEnabledFlag
.
Name
),
Discovery
:
!
ctx
.
GlobalBool
(
NoDiscoverFlag
.
Name
),
...
...
@@ -444,6 +449,13 @@ func MakeChain(ctx *cli.Context) (chain *core.ChainManager, blockDB, stateDB, ex
if
extraDB
,
err
=
ethdb
.
NewLDBDatabase
(
filepath
.
Join
(
datadir
,
"extra"
),
cache
);
err
!=
nil
{
Fatalf
(
"Could not open database: %v"
,
err
)
}
if
ctx
.
GlobalBool
(
OlympicFlag
.
Name
)
{
InitOlympic
()
_
,
err
:=
core
.
WriteTestNetGenesisBlock
(
stateDB
,
blockDB
,
42
)
if
err
!=
nil
{
glog
.
Fatalln
(
err
)
}
}
eventMux
:=
new
(
event
.
TypeMux
)
pow
:=
ethash
.
New
()
...
...
This diff is collapsed.
Click to expand it.
eth/backend.go
View file @
17b481e3
...
...
@@ -78,6 +78,7 @@ type Config struct {
GenesisNonce
int
GenesisFile
string
GenesisBlock
*
types
.
Block
// used by block tests
Olympic
bool
BlockChainVersion
int
SkipBcVersionCheck
bool
// e.g. blockchain export
...
...
@@ -302,6 +303,14 @@ func New(config *Config) (*Ethereum, error) {
glog
.
V
(
logger
.
Info
)
.
Infof
(
"Successfully wrote genesis block. New genesis hash = %x
\n
"
,
block
.
Hash
())
}
if
config
.
Olympic
{
_
,
err
:=
core
.
WriteTestNetGenesisBlock
(
stateDb
,
blockDb
,
42
)
if
err
!=
nil
{
return
nil
,
err
}
glog
.
V
(
logger
.
Error
)
.
Infoln
(
"Starting Olympic network"
)
}
// This is for testing only.
if
config
.
GenesisBlock
!=
nil
{
core
.
WriteBlock
(
blockDb
,
config
.
GenesisBlock
)
...
...
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