Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
69e745c5
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
69e745c5
编写于
10月 27, 2014
作者:
O
obscuren
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Return erroneous txs (so we can remove them from the pool)
上级
00328088
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
36 addition
and
7 deletion
+36
-7
ethchain/state_manager.go
ethchain/state_manager.go
+9
-6
ethchain/transaction.go
ethchain/transaction.go
+1
-1
ethchain/transaction_pool.go
ethchain/transaction_pool.go
+26
-0
未找到文件。
ethchain/state_manager.go
浏览文件 @
69e745c5
...
...
@@ -17,7 +17,7 @@ import (
"github.com/ethereum/go-ethereum/event"
)
var
statelogger
=
ethlog
.
NewLogger
(
"
STATE
"
)
var
statelogger
=
ethlog
.
NewLogger
(
"
BLOCK
"
)
type
Peer
interface
{
Inbound
()
bool
...
...
@@ -134,10 +134,11 @@ func (sm *StateManager) ChainManager() *ChainManager {
return
sm
.
bc
}
func
(
self
*
StateManager
)
ProcessTransactions
(
coinbase
*
ethstate
.
StateObject
,
state
*
ethstate
.
State
,
block
,
parent
*
Block
,
txs
Transactions
)
(
Receipts
,
Transactions
,
Transactions
,
error
)
{
func
(
self
*
StateManager
)
ProcessTransactions
(
coinbase
*
ethstate
.
StateObject
,
state
*
ethstate
.
State
,
block
,
parent
*
Block
,
txs
Transactions
)
(
Receipts
,
Transactions
,
Transactions
,
Transactions
,
error
)
{
var
(
receipts
Receipts
handled
,
unhandled
Transactions
erroneous
Transactions
totalUsedGas
=
big
.
NewInt
(
0
)
err
error
)
...
...
@@ -161,7 +162,9 @@ done:
break
done
default
:
statelogger
.
Infoln
(
err
)
erroneous
=
append
(
erroneous
,
tx
)
err
=
nil
continue
//return nil, nil, nil, err
}
}
...
...
@@ -182,7 +185,7 @@ done:
err
:=
fmt
.
Errorf
(
"#%d receipt failed (r) %v ~ %x <=> (c) %v ~ %x (%x...)"
,
i
+
1
,
original
.
CumulativeGasUsed
,
original
.
PostState
[
0
:
4
],
receipt
.
CumulativeGasUsed
,
receipt
.
PostState
[
0
:
4
],
receipt
.
Tx
.
Hash
()[
0
:
4
])
return
nil
,
nil
,
nil
,
err
return
nil
,
nil
,
nil
,
nil
,
err
}
}
...
...
@@ -199,7 +202,7 @@ done:
parent
.
GasUsed
=
totalUsedGas
return
receipts
,
handled
,
unhandled
,
err
return
receipts
,
handled
,
unhandled
,
err
oneous
,
err
}
func
(
sm
*
StateManager
)
Process
(
block
*
Block
,
dontReact
bool
)
(
err
error
)
{
...
...
@@ -283,7 +286,7 @@ func (sm *StateManager) Process(block *Block, dontReact bool) (err error) {
state
.
Manifest
()
.
Reset
()
}
sm
.
eth
.
TxPool
()
.
Remove
Invalid
(
state
)
sm
.
eth
.
TxPool
()
.
Remove
Set
(
block
.
Transactions
()
)
}
else
{
statelogger
.
Errorln
(
"total diff failed"
)
}
...
...
@@ -296,7 +299,7 @@ func (sm *StateManager) ApplyDiff(state *ethstate.State, parent, block *Block) (
coinbase
.
SetGasPool
(
block
.
CalcGasLimit
(
parent
))
// Process the transactions on to current block
receipts
,
_
,
_
,
err
=
sm
.
ProcessTransactions
(
coinbase
,
state
,
block
,
parent
,
block
.
Transactions
())
receipts
,
_
,
_
,
_
,
err
=
sm
.
ProcessTransactions
(
coinbase
,
state
,
block
,
parent
,
block
.
Transactions
())
if
err
!=
nil
{
return
nil
,
err
}
...
...
ethchain/transaction.go
浏览文件 @
69e745c5
...
...
@@ -40,7 +40,7 @@ func NewContractCreationTx(value, gas, gasPrice *big.Int, script []byte) *Transa
}
func
NewTransactionMessage
(
to
[]
byte
,
value
,
gas
,
gasPrice
*
big
.
Int
,
data
[]
byte
)
*
Transaction
{
return
&
Transaction
{
Recipient
:
to
,
Value
:
value
,
GasPrice
:
gasPrice
,
Gas
:
gas
,
Data
:
data
}
return
&
Transaction
{
Recipient
:
to
,
Value
:
value
,
GasPrice
:
gasPrice
,
Gas
:
gas
,
Data
:
data
,
contractCreation
:
IsContractAddr
(
to
)
}
}
func
NewTransactionFromBytes
(
data
[]
byte
)
*
Transaction
{
...
...
ethchain/transaction_pool.go
浏览文件 @
69e745c5
...
...
@@ -35,6 +35,14 @@ type TxMsg struct {
Type
TxMsgTy
}
func
EachTx
(
pool
*
list
.
List
,
it
func
(
*
Transaction
,
*
list
.
Element
)
bool
)
{
for
e
:=
pool
.
Front
();
e
!=
nil
;
e
=
e
.
Next
()
{
if
it
(
e
.
Value
.
(
*
Transaction
),
e
)
{
break
}
}
}
func
FindTx
(
pool
*
list
.
List
,
finder
func
(
*
Transaction
,
*
list
.
Element
)
bool
)
*
Transaction
{
for
e
:=
pool
.
Front
();
e
!=
nil
;
e
=
e
.
Next
()
{
if
tx
,
ok
:=
e
.
Value
.
(
*
Transaction
);
ok
{
...
...
@@ -191,6 +199,9 @@ func (pool *TxPool) CurrentTransactions() []*Transaction {
}
func
(
pool
*
TxPool
)
RemoveInvalid
(
state
*
ethstate
.
State
)
{
pool
.
mutex
.
Lock
()
defer
pool
.
mutex
.
Unlock
()
for
e
:=
pool
.
pool
.
Front
();
e
!=
nil
;
e
=
e
.
Next
()
{
tx
:=
e
.
Value
.
(
*
Transaction
)
sender
:=
state
.
GetAccount
(
tx
.
Sender
())
...
...
@@ -201,6 +212,21 @@ func (pool *TxPool) RemoveInvalid(state *ethstate.State) {
}
}
func
(
self
*
TxPool
)
RemoveSet
(
txs
Transactions
)
{
self
.
mutex
.
Lock
()
defer
self
.
mutex
.
Unlock
()
for
_
,
tx
:=
range
txs
{
EachTx
(
self
.
pool
,
func
(
t
*
Transaction
,
element
*
list
.
Element
)
bool
{
if
t
==
tx
{
self
.
pool
.
Remove
(
element
)
return
true
// To stop the loop
}
return
false
})
}
}
func
(
pool
*
TxPool
)
Flush
()
[]
*
Transaction
{
txList
:=
pool
.
CurrentTransactions
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录