Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
62ed083f
Commit
62ed083f
authored
Feb 20, 2018
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: remove unnecessary level of depth from runInVm
parent
adfdea8b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
46 deletions
+46
-46
txRunner.js
src/app/execution/txRunner.js
+46
-46
No files found.
src/app/execution/txRunner.js
View file @
62ed083f
...
@@ -68,60 +68,60 @@ TxRunner.prototype.execute = function (args, callback) {
...
@@ -68,60 +68,60 @@ TxRunner.prototype.execute = function (args, callback) {
if
(
!
executionContext
.
isVM
())
{
if
(
!
executionContext
.
isVM
())
{
self
.
runInNode
(
args
.
from
,
args
.
to
,
data
,
args
.
value
,
args
.
gasLimit
,
args
.
useCall
,
callback
)
self
.
runInNode
(
args
.
from
,
args
.
to
,
data
,
args
.
value
,
args
.
gasLimit
,
args
.
useCall
,
callback
)
}
else
{
}
else
{
self
.
runInVm
(
args
.
from
,
args
.
to
,
data
,
args
.
value
,
args
.
gasLimit
,
args
.
useCall
,
callback
)
try
{
self
.
runInVm
(
args
.
from
,
args
.
to
,
data
,
args
.
value
,
args
.
gasLimit
,
args
.
useCall
,
callback
)
}
catch
(
e
)
{
callback
(
e
,
null
)
}
}
}
}
}
TxRunner
.
prototype
.
runInVm
=
function
(
from
,
to
,
data
,
value
,
gasLimit
,
useCall
,
callback
)
{
TxRunner
.
prototype
.
runInVm
=
function
(
from
,
to
,
data
,
value
,
gasLimit
,
useCall
,
callback
)
{
const
self
=
this
const
self
=
this
try
{
var
account
=
self
.
vmaccounts
[
from
]
var
account
=
self
.
vmaccounts
[
from
]
if
(
!
account
)
{
if
(
!
account
)
{
return
callback
(
'Invalid account selected'
)
return
callback
(
'Invalid account selected'
)
}
}
var
tx
=
new
EthJSTX
({
var
tx
=
new
EthJSTX
({
nonce
:
new
BN
(
account
.
nonce
++
),
nonce
:
new
BN
(
account
.
nonce
++
),
gasPrice
:
new
BN
(
1
),
gasPrice
:
new
BN
(
1
),
gasLimit
:
new
BN
(
gasLimit
,
10
),
gasLimit
:
new
BN
(
gasLimit
,
10
),
to
:
to
,
to
:
to
,
value
:
new
BN
(
value
,
10
),
value
:
new
BN
(
value
,
10
),
data
:
new
Buffer
(
data
.
slice
(
2
),
'hex'
)
data
:
new
Buffer
(
data
.
slice
(
2
),
'hex'
)
})
})
tx
.
sign
(
account
.
privateKey
)
tx
.
sign
(
account
.
privateKey
)
const
coinbases
=
[
'0x0e9281e9c6a0808672eaba6bd1220e144c9bb07a'
,
'0x8945a1288dc78a6d8952a92c77aee6730b414778'
,
'0x94d76e24f818426ae84aa404140e8d5f60e10e7e'
]
const
coinbases
=
[
'0x0e9281e9c6a0808672eaba6bd1220e144c9bb07a'
,
'0x8945a1288dc78a6d8952a92c77aee6730b414778'
,
'0x94d76e24f818426ae84aa404140e8d5f60e10e7e'
]
const
difficulties
=
[
new
BN
(
'69762765929000'
,
10
),
new
BN
(
'70762765929000'
,
10
),
new
BN
(
'71762765929000'
,
10
)
]
const
difficulties
=
[
new
BN
(
'69762765929000'
,
10
),
new
BN
(
'70762765929000'
,
10
),
new
BN
(
'71762765929000'
,
10
)
]
var
block
=
new
EthJSBlock
({
var
block
=
new
EthJSBlock
({
header
:
{
header
:
{
timestamp
:
new
Date
().
getTime
()
/
1000
|
0
,
timestamp
:
new
Date
().
getTime
()
/
1000
|
0
,
number
:
self
.
blockNumber
,
number
:
self
.
blockNumber
,
coinbase
:
coinbases
[
self
.
blockNumber
%
coinbases
.
length
],
coinbase
:
coinbases
[
self
.
blockNumber
%
coinbases
.
length
],
difficulty
:
difficulties
[
self
.
blockNumber
%
difficulties
.
length
],
difficulty
:
difficulties
[
self
.
blockNumber
%
difficulties
.
length
],
gasLimit
:
new
BN
(
gasLimit
,
10
).
imuln
(
2
)
gasLimit
:
new
BN
(
gasLimit
,
10
).
imuln
(
2
)
},
},
transactions
:
[],
transactions
:
[],
uncleHeaders
:
[]
uncleHeaders
:
[]
})
})
if
(
!
useCall
)
{
if
(
!
useCall
)
{
++
self
.
blockNumber
++
self
.
blockNumber
}
else
{
}
else
{
executionContext
.
vm
().
stateManager
.
checkpoint
()
executionContext
.
vm
().
stateManager
.
checkpoint
()
}
}
executionContext
.
vm
().
runTx
({
block
:
block
,
tx
:
tx
,
skipBalance
:
true
,
skipNonce
:
true
},
function
(
err
,
result
)
{
executionContext
.
vm
().
runTx
({
block
:
block
,
tx
:
tx
,
skipBalance
:
true
,
skipNonce
:
true
},
function
(
err
,
result
)
{
if
(
useCall
)
{
if
(
useCall
)
{
executionContext
.
vm
().
stateManager
.
revert
(
function
()
{})
executionContext
.
vm
().
stateManager
.
revert
(
function
()
{})
}
}
err
=
err
?
err
.
message
:
err
err
=
err
?
err
.
message
:
err
result
.
status
=
'0x'
+
result
.
vm
.
exception
.
toString
(
16
)
result
.
status
=
'0x'
+
result
.
vm
.
exception
.
toString
(
16
)
callback
(
err
,
{
callback
(
err
,
{
result
:
result
,
result
:
result
,
transactionHash
:
ethJSUtil
.
bufferToHex
(
new
Buffer
(
tx
.
hash
()))
transactionHash
:
ethJSUtil
.
bufferToHex
(
new
Buffer
(
tx
.
hash
()))
})
})
})
}
catch
(
e
)
{
})
callback
(
e
,
null
)
}
}
}
TxRunner
.
prototype
.
runInNode
=
function
(
from
,
to
,
data
,
value
,
gasLimit
,
useCall
,
callback
)
{
TxRunner
.
prototype
.
runInNode
=
function
(
from
,
to
,
data
,
value
,
gasLimit
,
useCall
,
callback
)
{
...
...
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