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
1bce02ef
Commit
1bce02ef
authored
Nov 28, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Plain Diff
Fixed merge
parents
8cf9ed0e
a3559c5e
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
76 additions
and
69 deletions
+76
-69
block_manager.go
chain/block_manager.go
+4
-3
chain_manager.go
chain/chain_manager.go
+0
-2
genesis.go
chain/genesis.go
+0
-2
state_transition.go
chain/state_transition.go
+15
-3
block.go
chain/types/block.go
+14
-22
main.go
cmd/ethereum/main.go
+2
-1
main.go
cmd/mist/main.go
+1
-1
install.sh
install.sh
+22
-19
miner.go
miner/miner.go
+1
-2
peer.go
peer.go
+1
-1
state.go
state/state.go
+16
-13
No files found.
chain/block_manager.go
View file @
1bce02ef
...
...
@@ -155,10 +155,11 @@ done:
}
}
txGas
.
Sub
(
txGas
,
st
.
gas
)
// Update the state with pending changes
state
.
Update
()
state
.
Update
(
txGas
)
txGas
.
Sub
(
txGas
,
st
.
gas
)
cumulative
:=
new
(
big
.
Int
)
.
Set
(
totalUsedGas
.
Add
(
totalUsedGas
,
txGas
))
receipt
:=
types
.
NewReceipt
(
state
.
Root
(),
cumulative
)
receipt
.
SetLogs
(
state
.
Logs
())
...
...
@@ -247,7 +248,7 @@ func (sm *BlockManager) ProcessWithParent(block, parent *types.Block) (td *big.I
return
}
state
.
Update
()
state
.
Update
(
nil
)
if
!
block
.
State
()
.
Cmp
(
state
)
{
err
=
fmt
.
Errorf
(
"invalid merkle root. received=%x got=%x"
,
block
.
Root
(),
state
.
Root
())
...
...
chain/chain_manager.go
View file @
1bce02ef
...
...
@@ -112,8 +112,6 @@ func (bc *ChainManager) NewBlock(coinbase []byte) *types.Block {
nil
,
""
)
block
.
MinGasPrice
=
big
.
NewInt
(
10000000000000
)
parent
:=
bc
.
CurrentBlock
if
parent
!=
nil
{
block
.
Difficulty
=
CalcDifficulty
(
block
,
parent
)
...
...
chain/genesis.go
View file @
1bce02ef
...
...
@@ -37,8 +37,6 @@ var GenesisHeader = []interface{}{
big
.
NewInt
(
131072
),
// Number
ethutil
.
Big0
,
// Block minimum gas price
ethutil
.
Big0
,
// Block upper gas bound
big
.
NewInt
(
1000000
),
// Block gas used
...
...
chain/state_transition.go
View file @
1bce02ef
...
...
@@ -157,12 +157,24 @@ func (self *StateTransition) TransitionState() (err error) {
}
// Pay data gas
dataPrice
:=
big
.
NewInt
(
int64
(
len
(
self
.
data
)))
dataPrice
.
Mul
(
dataPrice
,
vm
.
GasData
)
if
err
=
self
.
UseGas
(
dataPrice
);
err
!=
nil
{
var
dgas
int64
for
_
,
byt
:=
range
self
.
data
{
if
byt
!=
0
{
dgas
+=
vm
.
GasData
.
Int64
()
}
else
{
dgas
+=
1
// This is 1/5. If GasData changes this fails
}
}
if
err
=
self
.
UseGas
(
big
.
NewInt
(
dgas
));
err
!=
nil
{
return
}
//dataPrice := big.NewInt(int64(len(self.data)))
//dataPrice.Mul(dataPrice, vm.GasData)
//if err = self.UseGas(dataPrice); err != nil {
// return
//}
if
sender
.
Balance
()
.
Cmp
(
self
.
value
)
<
0
{
return
fmt
.
Errorf
(
"Insufficient funds to transfer value. Req %v, has %v"
,
self
.
value
,
sender
.
Balance
)
}
...
...
chain/types/block.go
View file @
1bce02ef
...
...
@@ -84,8 +84,6 @@ type Block struct {
Time
int64
// The block number
Number
*
big
.
Int
// Minimum Gas Price
MinGasPrice
*
big
.
Int
// Gas limit
GasLimit
*
big
.
Int
// Gas used
...
...
@@ -132,7 +130,6 @@ func CreateBlock(root interface{},
Extra
:
extra
,
UncleSha
:
nil
,
GasUsed
:
new
(
big
.
Int
),
MinGasPrice
:
new
(
big
.
Int
),
GasLimit
:
new
(
big
.
Int
),
}
block
.
SetUncles
([]
*
Block
{})
...
...
@@ -300,12 +297,11 @@ func (self *Block) setHeader(header *ethutil.Value) {
self
.
LogsBloom
=
header
.
Get
(
6
)
.
Bytes
()
self
.
Difficulty
=
header
.
Get
(
7
)
.
BigInt
()
self
.
Number
=
header
.
Get
(
8
)
.
BigInt
()
self
.
MinGasPrice
=
header
.
Get
(
9
)
.
BigInt
()
self
.
GasLimit
=
header
.
Get
(
10
)
.
BigInt
()
self
.
GasUsed
=
header
.
Get
(
11
)
.
BigInt
()
self
.
Time
=
int64
(
header
.
Get
(
12
)
.
BigInt
()
.
Uint64
())
self
.
Extra
=
header
.
Get
(
13
)
.
Str
()
self
.
Nonce
=
header
.
Get
(
14
)
.
Bytes
()
self
.
GasLimit
=
header
.
Get
(
9
)
.
BigInt
()
self
.
GasUsed
=
header
.
Get
(
10
)
.
BigInt
()
self
.
Time
=
int64
(
header
.
Get
(
11
)
.
BigInt
()
.
Uint64
())
self
.
Extra
=
header
.
Get
(
12
)
.
Str
()
self
.
Nonce
=
header
.
Get
(
13
)
.
Bytes
()
}
func
NewUncleBlockFromValue
(
header
*
ethutil
.
Value
)
*
Block
{
...
...
@@ -351,8 +347,6 @@ func (block *Block) miningHeader() []interface{} {
block
.
Difficulty
,
// The block number
block
.
Number
,
// Block minimum gas price
block
.
MinGasPrice
,
// Block upper gas bound
block
.
GasLimit
,
// Block gas used
...
...
@@ -380,7 +374,6 @@ func (block *Block) String() string {
Bloom: %x
Difficulty: %v
Number: %v
MinGas: %v
MaxLimit: %v
GasUsed: %v
Time: %v
...
...
@@ -399,7 +392,6 @@ func (block *Block) String() string {
block
.
LogsBloom
,
block
.
Difficulty
,
block
.
Number
,
block
.
MinGasPrice
,
block
.
GasLimit
,
block
.
GasUsed
,
block
.
Time
,
...
...
cmd/ethereum/main.go
View file @
1bce02ef
...
...
@@ -21,6 +21,7 @@ import (
"fmt"
"os"
"runtime"
"github.com/ethereum/go-ethereum/chain/types"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/ethutil"
...
...
@@ -29,7 +30,7 @@ import (
const
(
ClientIdentifier
=
"Ethereum(G)"
Version
=
"0.7.
5
"
Version
=
"0.7.
6
"
)
var
clilogger
=
logger
.
NewLogger
(
"CLI"
)
...
...
cmd/mist/main.go
View file @
1bce02ef
...
...
@@ -31,7 +31,7 @@ import (
const
(
ClientIdentifier
=
"Mist"
Version
=
"0.7.
5
"
Version
=
"0.7.
6
"
)
var
ethereum
*
eth
.
Ethereum
...
...
install.sh
View file @
1bce02ef
#!/bin/sh
if
[
"
$1
"
==
""
]
;
then
echo
"Usage
$0
executable branch
ethereum develop
"
echo
"executable ethereum
or
mist"
echo
"branch develop
or
master"
echo
"Usage
$0
executable branch"
echo
"executable ethereum
|
mist"
echo
"branch develop
|
master"
exit
fi
exe
=
$1
path
=
$exe
branch
=
$2
if
[
"
$branch
"
==
"develop"
]
;
then
path
=
"cmd/
$exe
"
fi
# Test if go is installed
command
-v
go
>
/dev/null 2>&1
||
{
echo
>
&2
"Unable to find 'go'. This script requires go."
;
exit
1
;
}
...
...
@@ -19,20 +24,23 @@ if [ "$GOPATH" == "" ]; then
exit
fi
echo
"go get -u -d github.com/ethereum/go-ethereum/
$exe
"
go get
-v
-u
-d
github.com/ethereum/go-ethereum/
$exe
if
[
$?
!=
0
]
;
then
echo
"go get failed"
exit
fi
echo
"eth-go"
echo
"changing branch to
$branch
"
cd
$GOPATH
/src/github.com/ethereum/go-ethereum
git checkout
$branch
echo
"go-ethereum"
cd
$GOPATH
/src/github.com/ethereum/go-ethereum/
$exe
git checkout
$branch
# installing package dependencies doesn't work for develop
# branch as go get always pulls from master head
# so build will continue to fail, but this installs locally
# for people who git clone since go install will manage deps
#echo "go get -u -d github.com/ethereum/go-ethereum/$path"
#go get -v -u -d github.com/ethereum/go-ethereum/$path
#if [ $? != 0 ]; then
# echo "go get failed"
# exit
#fi
cd
$GOPATH
/src/github.com/ethereum/go-ethereum/
$path
if
[
"
$exe
"
==
"mist"
]
;
then
echo
"Building Mist GUI. Assuming Qt is installed. If this step"
...
...
@@ -42,9 +50,4 @@ else
fi
go
install
if
[
$?
==
0
]
;
then
echo
"go install failed"
exit
fi
echo
"done. Please run
$exe
:-)"
miner/miner.go
View file @
1bce02ef
...
...
@@ -179,7 +179,6 @@ func (self *Miner) mine() {
chainMan
=
self
.
eth
.
ChainManager
()
block
=
chainMan
.
NewBlock
(
self
.
Coinbase
)
)
block
.
MinGasPrice
=
self
.
MinAcceptedGasPrice
// Apply uncles
if
len
(
self
.
uncles
)
>
0
{
...
...
@@ -206,7 +205,7 @@ func (self *Miner) mine() {
// Accumulate the rewards included for this block
blockManager
.
AccumelateRewards
(
block
.
State
(),
block
,
parent
)
block
.
State
()
.
Update
()
block
.
State
()
.
Update
(
nil
)
minerlogger
.
Infof
(
"Mining on block. Includes %v transactions"
,
len
(
transactions
))
...
...
peer.go
View file @
1bce02ef
...
...
@@ -24,7 +24,7 @@ const (
// The size of the output buffer for writing messages
outputBufferSize
=
50
// Current protocol version
ProtocolVersion
=
4
3
ProtocolVersion
=
4
5
// Current P2P version
P2PVersion
=
2
// Ethereum network version
...
...
state/state.go
View file @
1bce02ef
...
...
@@ -23,14 +23,14 @@ type State struct {
manifest
*
Manifest
refund
map
[
string
]
*
big
.
Int
refund
map
[
string
]
[]
refund
logs
Logs
}
// Create a new state from a given trie
func
New
(
trie
*
trie
.
Trie
)
*
State
{
return
&
State
{
Trie
:
trie
,
stateObjects
:
make
(
map
[
string
]
*
StateObject
),
manifest
:
NewManifest
(),
refund
:
make
(
map
[
string
]
*
big
.
Int
)}
return
&
State
{
Trie
:
trie
,
stateObjects
:
make
(
map
[
string
]
*
StateObject
),
manifest
:
NewManifest
(),
refund
:
make
(
map
[
string
]
[]
refund
)}
}
func
(
self
*
State
)
EmptyLogs
()
{
...
...
@@ -55,14 +55,12 @@ func (self *State) GetBalance(addr []byte) *big.Int {
return
ethutil
.
Big0
}
func
(
self
*
State
)
Refund
(
addr
[]
byte
,
gas
,
price
*
big
.
Int
)
{
amount
:=
new
(
big
.
Int
)
.
Mul
(
gas
,
price
)
if
self
.
refund
[
string
(
addr
)]
==
nil
{
self
.
refund
[
string
(
addr
)]
=
new
(
big
.
Int
)
}
type
refund
struct
{
gas
,
price
*
big
.
Int
}
self
.
refund
[
string
(
addr
)]
.
Add
(
self
.
refund
[
string
(
addr
)],
amount
)
func
(
self
*
State
)
Refund
(
addr
[]
byte
,
gas
,
price
*
big
.
Int
)
{
self
.
refund
[
string
(
addr
)]
=
append
(
self
.
refund
[
string
(
addr
)],
refund
{
gas
,
price
})
}
func
(
self
*
State
)
AddBalance
(
addr
[]
byte
,
amount
*
big
.
Int
)
{
...
...
@@ -276,15 +274,20 @@ func (s *State) Sync() {
func
(
self
*
State
)
Empty
()
{
self
.
stateObjects
=
make
(
map
[
string
]
*
StateObject
)
self
.
refund
=
make
(
map
[
string
]
*
big
.
Int
)
self
.
refund
=
make
(
map
[
string
]
[]
refund
)
}
func
(
self
*
State
)
Update
()
{
func
(
self
*
State
)
Update
(
gasUsed
*
big
.
Int
)
{
var
deleted
bool
// Refund any gas that's left
for
addr
,
amount
:=
range
self
.
refund
{
self
.
GetStateObject
([]
byte
(
addr
))
.
AddBalance
(
amount
)
uhalf
:=
new
(
big
.
Int
)
.
Div
(
gasUsed
,
ethutil
.
Big2
)
for
addr
,
refs
:=
range
self
.
refund
{
for
_
,
ref
:=
range
refs
{
refund
:=
ethutil
.
BigMin
(
uhalf
,
ref
.
gas
)
self
.
GetStateObject
([]
byte
(
addr
))
.
AddBalance
(
refund
.
Mul
(
refund
,
ref
.
price
))
}
}
for
_
,
stateObject
:=
range
self
.
stateObjects
{
...
...
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