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
cd9dd507
Commit
cd9dd507
authored
Jan 06, 2017
by
Alex Beregszaszi
Committed by
GitHub
Jan 06, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #361 from ethereum/checkgasblocklimit
Check the current block gas limit before sending the tx
parents
293b12fa
2a703772
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
13 deletions
+20
-13
txRunner.js
src/app/txRunner.js
+20
-13
No files found.
src/app/txRunner.js
View file @
cd9dd507
...
@@ -65,25 +65,32 @@ TxRunner.prototype.execute = function () {
...
@@ -65,25 +65,32 @@ TxRunner.prototype.execute = function () {
})
})
})
})
}
else
{
}
else
{
self
.
web3
.
eth
.
estimateGas
(
tx
,
function
(
err
,
resp
)
{
self
.
web3
.
eth
.
estimateGas
(
tx
,
function
(
err
,
gasEstimation
)
{
if
(
err
)
{
if
(
err
)
{
return
callback
(
err
,
resp
)
return
callback
(
err
,
gasEstimation
)
}
if
(
resp
>
gasLimit
)
{
return
callback
(
'Gas required exceeds limit: '
+
resp
)
}
}
self
.
web3
.
eth
.
getBlock
(
'latest'
,
function
(
err
,
block
)
{
if
(
err
)
{
return
callback
(
err
)
}
else
{
// NOTE: estimateGas very likely will return a large limit if execution of the code failed
// we want to be able to run the code in order to debug and find the cause for the failure
var
blockGasLimit
=
Math
.
floor
(
block
.
gasLimit
-
block
.
gasLimit
/
1024
)
tx
.
gas
=
blockGasLimit
<
gasEstimation
?
blockGasLimit
:
gasEstimation
tx
.
gas
=
resp
if
(
tx
.
gas
>
gasLimit
)
{
return
callback
(
'Gas required exceeds limit: '
+
tx
.
gas
)
}
var
sendTransaction
=
self
.
personalMode
?
self
.
web3
.
personal
.
sendTransaction
:
self
.
web3
.
eth
.
sendTransaction
var
sendTransaction
=
self
.
personalMode
?
self
.
web3
.
personal
.
sendTransaction
:
self
.
web3
.
eth
.
sendTransaction
sendTransaction
(
tx
,
function
(
err
,
resp
)
{
if
(
err
)
{
return
callback
(
err
,
resp
)
}
sendTransaction
(
tx
,
function
(
err
,
resp
)
{
tryTillResponse
(
self
.
web3
,
resp
,
callback
)
if
(
err
)
{
})
return
callback
(
err
,
resp
)
}
}
tryTillResponse
(
self
.
web3
,
resp
,
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