good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
c1d70ea9
Commit
c1d70ea9
authored
Jan 29, 2018
by
mark.lin
Browse files
Options
Downloads
Patches
Plain Diff
accounts/abi, core: add AddTxWithChain in BlockGen for simulation
parent
05ade193
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
accounts/abi/bind/backends/simulated.go
+2
-2
2 additions, 2 deletions
accounts/abi/bind/backends/simulated.go
core/chain_makers.go
+13
-1
13 additions, 1 deletion
core/chain_makers.go
with
15 additions
and
3 deletions
accounts/abi/bind/backends/simulated.go
+
2
−
2
View file @
c1d70ea9
...
...
@@ -293,9 +293,9 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa
blocks
,
_
:=
core
.
GenerateChain
(
b
.
config
,
b
.
blockchain
.
CurrentBlock
(),
ethash
.
NewFaker
(),
b
.
database
,
1
,
func
(
number
int
,
block
*
core
.
BlockGen
)
{
for
_
,
tx
:=
range
b
.
pendingBlock
.
Transactions
()
{
block
.
AddTx
(
tx
)
block
.
AddTx
WithChain
(
b
.
blockchain
,
tx
)
}
block
.
AddTx
(
tx
)
block
.
AddTx
WithChain
(
b
.
blockchain
,
tx
)
})
b
.
pendingBlock
=
blocks
[
0
]
b
.
pendingState
,
_
=
state
.
New
(
b
.
pendingBlock
.
Root
(),
state
.
NewDatabase
(
b
.
database
))
...
...
This diff is collapsed.
Click to expand it.
core/chain_makers.go
+
13
−
1
View file @
c1d70ea9
...
...
@@ -82,11 +82,23 @@ func (b *BlockGen) SetExtra(data []byte) {
// added. Notably, contract code relying on the BLOCKHASH instruction
// will panic during execution.
func
(
b
*
BlockGen
)
AddTx
(
tx
*
types
.
Transaction
)
{
b
.
AddTxWithChain
(
nil
,
tx
)
}
// AddTxWithChain adds a transaction to the generated block. If no coinbase has
// been set, the block's coinbase is set to the zero address.
//
// AddTxWithChain panics if the transaction cannot be executed. In addition to
// the protocol-imposed limitations (gas limit, etc.), there are some
// further limitations on the content of transactions that can be
// added. If contract code relies on the BLOCKHASH instruction,
// the block in chain will be returned.
func
(
b
*
BlockGen
)
AddTxWithChain
(
bc
*
BlockChain
,
tx
*
types
.
Transaction
)
{
if
b
.
gasPool
==
nil
{
b
.
SetCoinbase
(
common
.
Address
{})
}
b
.
statedb
.
Prepare
(
tx
.
Hash
(),
common
.
Hash
{},
len
(
b
.
txs
))
receipt
,
_
,
err
:=
ApplyTransaction
(
b
.
config
,
nil
,
&
b
.
header
.
Coinbase
,
b
.
gasPool
,
b
.
statedb
,
b
.
header
,
tx
,
&
b
.
header
.
GasUsed
,
vm
.
Config
{})
receipt
,
_
,
err
:=
ApplyTransaction
(
b
.
config
,
bc
,
&
b
.
header
.
Coinbase
,
b
.
gasPool
,
b
.
statedb
,
b
.
header
,
tx
,
&
b
.
header
.
GasUsed
,
vm
.
Config
{})
if
err
!=
nil
{
panic
(
err
)
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment