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
aa4c2577
Commit
aa4c2577
authored
Apr 26, 2015
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #813 from obscuren/general_fixes
General fixes
parents
8d09f95b
7fd368c5
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
23 additions
and
25 deletions
+23
-25
main.go
cmd/geth/main.go
+2
-1
ethereum.js
cmd/mist/assets/ext/ethereum.js
+1
-1
chain_makers.go
core/chain_makers.go
+2
-2
chain_manager.go
core/chain_manager.go
+3
-7
transaction_pool.go
core/transaction_pool.go
+9
-9
transaction_pool_test.go
core/transaction_pool_test.go
+3
-2
ethereum_js.go
jsre/ethereum_js.go
+2
-2
worker.go
miner/worker.go
+1
-1
No files found.
cmd/geth/main.go
View file @
aa4c2577
...
...
@@ -266,7 +266,8 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
}
func
main
()
{
fmt
.
Printf
(
"
\n
🌞
\n\n
ᴡᴇʟᴄᴏᴍᴇ ᴛᴏ ᴛʜᴇ
\n
𝐅 𝐑 𝐎 𝐍 𝐓 𝐈 𝐄 𝐑
\n\n
🌾 🌵🌾🌾 🐎 🌾 🌵 🌾
\n\n
"
)
//fmt.Printf("\n 🌞\n\n ᴡᴇʟᴄᴏᴍᴇ ᴛᴏ ᴛʜᴇ\n 𝐅 𝐑 𝐎 𝐍 𝐓 𝐈 𝐄 𝐑\n\n🌾 🌵🌾🌾 🐎 🌾 🌵 🌾\n\n")
fmt
.
Println
(
"
\n
Welcome to the
\n
FRONTIER
\n
"
)
runtime
.
GOMAXPROCS
(
runtime
.
NumCPU
())
defer
logger
.
Flush
()
if
err
:=
app
.
Run
(
os
.
Args
);
err
!=
nil
{
...
...
ethereum.js
@
3b799d12
Subproject commit
f8a43eddfb450d0e0ba1669a6916babe0ea43642
Subproject commit
3b799d128452639463424c657956ee90a28daec6
core/chain_makers.go
View file @
aa4c2577
...
...
@@ -64,7 +64,7 @@ func newBlockFromParent(addr common.Address, parent *types.Block) *types.Block {
header
.
Difficulty
=
CalcDifficulty
(
block
.
Header
(),
parent
.
Header
())
header
.
Number
=
new
(
big
.
Int
)
.
Add
(
parent
.
Header
()
.
Number
,
common
.
Big1
)
header
.
Time
=
parent
.
Header
()
.
Time
+
10
header
.
GasLimit
=
CalcGasLimit
(
parent
,
block
)
header
.
GasLimit
=
CalcGasLimit
(
parent
)
block
.
Td
=
parent
.
Td
...
...
@@ -79,7 +79,7 @@ func makeBlock(bman *BlockProcessor, parent *types.Block, i int, db common.Datab
block
:=
newBlockFromParent
(
addr
,
parent
)
state
:=
state
.
New
(
block
.
Root
(),
db
)
cbase
:=
state
.
GetOrNewStateObject
(
addr
)
cbase
.
SetGasPool
(
CalcGasLimit
(
parent
,
block
))
cbase
.
SetGasPool
(
CalcGasLimit
(
parent
))
cbase
.
AddBalance
(
BlockReward
)
state
.
Update
()
block
.
SetRoot
(
state
.
Root
())
...
...
core/chain_manager.go
View file @
aa4c2577
...
...
@@ -54,11 +54,7 @@ func CalculateTD(block, parent *types.Block) *big.Int {
return
td
}
func
CalcGasLimit
(
parent
,
block
*
types
.
Block
)
*
big
.
Int
{
if
block
.
Number
()
.
Cmp
(
big
.
NewInt
(
0
))
==
0
{
return
common
.
BigPow
(
10
,
6
)
}
func
CalcGasLimit
(
parent
*
types
.
Block
)
*
big
.
Int
{
// ((1024-1) * parent.gasLimit + (gasUsed * 6 / 5)) / 1024
previous
:=
new
(
big
.
Int
)
.
Mul
(
big
.
NewInt
(
1024
-
1
),
parent
.
GasLimit
())
current
:=
new
(
big
.
Rat
)
.
Mul
(
new
(
big
.
Rat
)
.
SetInt
(
parent
.
GasUsed
()),
big
.
NewRat
(
6
,
5
))
...
...
@@ -277,7 +273,7 @@ func (bc *ChainManager) NewBlock(coinbase common.Address) *types.Block {
header
:=
block
.
Header
()
header
.
Difficulty
=
CalcDifficulty
(
block
.
Header
(),
parent
.
Header
())
header
.
Number
=
new
(
big
.
Int
)
.
Add
(
parent
.
Header
()
.
Number
,
common
.
Big1
)
header
.
GasLimit
=
CalcGasLimit
(
parent
,
block
)
header
.
GasLimit
=
CalcGasLimit
(
parent
)
}
...
...
@@ -658,7 +654,7 @@ out:
// We need some control over the mining operation. Acquiring locks and waiting for the miner to create new block takes too long
// and in most cases isn't even necessary.
if
i
+
1
==
ev
.
canonicalCount
{
self
.
currentGasLimit
=
CalcGasLimit
(
self
.
GetBlock
(
event
.
Block
.
ParentHash
()),
event
.
Block
)
self
.
currentGasLimit
=
CalcGasLimit
(
event
.
Block
)
self
.
eventMux
.
Post
(
ChainHeadEvent
{
event
.
Block
})
}
case
ChainSplitEvent
:
...
...
core/transaction_pool.go
View file @
aa4c2577
...
...
@@ -20,8 +20,9 @@ import (
var
(
ErrInvalidSender
=
errors
.
New
(
"Invalid sender"
)
ErrNonce
=
errors
.
New
(
"Nonce too low"
)
ErrBalance
=
errors
.
New
(
"Insufficient balance"
)
ErrNonExistentAccount
=
errors
.
New
(
"Account does not exist"
)
ErrInsufficientFunds
=
errors
.
New
(
"Insufficient funds"
)
ErrInsufficientFunds
=
errors
.
New
(
"Insufficient funds
for gas * price + value
"
)
ErrIntrinsicGas
=
errors
.
New
(
"Intrinsic gas too low"
)
ErrGasLimit
=
errors
.
New
(
"Exceeds block gas limit"
)
)
...
...
@@ -124,7 +125,9 @@ func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error {
return
ErrGasLimit
}
if
pool
.
currentState
()
.
GetBalance
(
from
)
.
Cmp
(
new
(
big
.
Int
)
.
Mul
(
tx
.
Price
,
tx
.
GasLimit
))
<
0
{
total
:=
new
(
big
.
Int
)
.
Mul
(
tx
.
Price
,
tx
.
GasLimit
)
total
.
Add
(
total
,
tx
.
Value
())
if
pool
.
currentState
()
.
GetBalance
(
from
)
.
Cmp
(
total
)
<
0
{
return
ErrInsufficientFunds
}
...
...
@@ -193,7 +196,7 @@ func (self *TxPool) AddTransactions(txs []*types.Transaction) {
for
_
,
tx
:=
range
txs
{
if
err
:=
self
.
add
(
tx
);
err
!=
nil
{
glog
.
V
(
logger
.
Debug
)
.
Infoln
(
err
)
glog
.
V
(
logger
.
Debug
)
.
Infoln
(
"tx error:"
,
err
)
}
else
{
h
:=
tx
.
Hash
()
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"tx %x
\n
"
,
h
[
:
4
])
...
...
@@ -296,7 +299,6 @@ func (pool *TxPool) checkQueue() {
pool
.
addTx
(
tx
)
}
//pool.queue[address] = txs[i:]
// delete the entire queue entry if it's empty. There's no need to keep it
if
len
(
pool
.
queue
[
address
])
==
0
{
delete
(
pool
.
queue
,
address
)
...
...
@@ -308,12 +310,10 @@ func (pool *TxPool) validatePool() {
pool
.
mu
.
Lock
()
defer
pool
.
mu
.
Unlock
()
statedb
:=
pool
.
currentState
()
for
hash
,
tx
:=
range
pool
.
txs
{
from
,
_
:=
tx
.
From
()
if
nonce
:=
statedb
.
GetNonce
(
from
);
nonce
>
tx
.
Nonce
()
{
if
glog
.
V
(
logger
.
Debug
)
{
glog
.
Infof
(
"removed tx (%x) from pool due to nonce error. state=%d tx=%d
\n
"
,
hash
[
:
4
],
nonce
,
tx
.
Nonce
())
if
err
:=
pool
.
ValidateTransaction
(
tx
);
err
!=
nil
{
if
glog
.
V
(
logger
.
Info
)
{
glog
.
Infof
(
"removed tx (%x) from pool: %v
\n
"
,
hash
[
:
4
],
err
)
}
delete
(
pool
.
txs
,
hash
)
...
...
core/transaction_pool_test.go
View file @
aa4c2577
...
...
@@ -43,10 +43,11 @@ func TestInvalidTransactions(t *testing.T) {
t
.
Error
(
"expected"
,
ErrInsufficientFunds
)
}
pool
.
currentState
()
.
AddBalance
(
from
,
big
.
NewInt
(
100
*
100
))
balance
:=
new
(
big
.
Int
)
.
Add
(
tx
.
Value
(),
new
(
big
.
Int
)
.
Mul
(
tx
.
Gas
(),
tx
.
GasPrice
()))
pool
.
currentState
()
.
AddBalance
(
from
,
balance
)
err
=
pool
.
Add
(
tx
)
if
err
!=
ErrIntrinsicGas
{
t
.
Error
(
"expected"
,
ErrIntrinsicGas
)
t
.
Error
(
"expected"
,
ErrIntrinsicGas
,
"got"
,
err
)
}
pool
.
currentState
()
.
SetNonce
(
from
,
1
)
...
...
jsre/ethereum_js.go
View file @
aa4c2577
This diff is collapsed.
Click to expand it.
miner/worker.go
View file @
aa4c2577
...
...
@@ -236,7 +236,7 @@ func (self *worker) makeCurrent() {
}
parent
:=
self
.
chain
.
GetBlock
(
self
.
current
.
block
.
ParentHash
())
self
.
current
.
coinbase
.
SetGasPool
(
core
.
CalcGasLimit
(
parent
,
self
.
current
.
block
))
self
.
current
.
coinbase
.
SetGasPool
(
core
.
CalcGasLimit
(
parent
))
}
func
(
self
*
worker
)
commitNewWork
()
{
...
...
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