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
1387bf86
Unverified
Commit
1387bf86
authored
Mar 01, 2018
by
yann300
Committed by
GitHub
Mar 01, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #711 from ethereum/fixBlockPolling
fix getBlock/SetInterval && update block gas limit when provider change
parents
c5722689
3bc91d4b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
11 deletions
+17
-11
execution-context.js
remix-lib/src/execution/execution-context.js
+17
-11
No files found.
remix-lib/src/execution/execution-context.js
View file @
1387bf86
...
@@ -173,6 +173,7 @@ function ExecutionContext () {
...
@@ -173,6 +173,7 @@ function ExecutionContext () {
}
else
{
}
else
{
executionContext
=
context
executionContext
=
context
web3
.
setProvider
(
injectedProvider
)
web3
.
setProvider
(
injectedProvider
)
self
.
_updateBlockGasLimit
()
self
.
event
.
trigger
(
'contextChanged'
,
[
'injected'
])
self
.
event
.
trigger
(
'contextChanged'
,
[
'injected'
])
return
cb
()
return
cb
()
}
}
...
@@ -192,19 +193,23 @@ function ExecutionContext () {
...
@@ -192,19 +193,23 @@ function ExecutionContext () {
this
.
listenOnLastBlockId
=
null
this
.
listenOnLastBlockId
=
null
}
}
this
.
_updateBlockGasLimit
=
function
()
{
if
(
this
.
getProvider
()
!==
'vm'
)
{
web3
.
eth
.
getBlock
(
'latest'
,
(
err
,
block
)
=>
{
if
(
!
err
)
{
// we can't use the blockGasLimit cause the next blocks could have a lower limit : https://github.com/ethereum/remix/issues/506
this
.
blockGasLimit
=
(
block
&&
block
.
gasLimit
)
?
Math
.
floor
(
block
.
gasLimit
-
(
5
*
block
.
gasLimit
)
/
1024
)
:
this
.
blockGasLimitDefault
}
else
{
this
.
blockGasLimit
=
this
.
blockGasLimitDefault
}
})
}
}
this
.
listenOnLastBlock
=
function
()
{
this
.
listenOnLastBlock
=
function
()
{
this
.
listenOnLastBlockId
=
setInterval
(()
=>
{
this
.
listenOnLastBlockId
=
setInterval
(()
=>
{
if
(
this
.
getProvider
()
!==
'vm'
)
{
this
.
_updateBlockGasLimit
()
web3
.
eth
.
getBlock
(
'latest'
,
(
err
,
block
)
=>
{
},
15000
)
if
(
!
err
)
{
// we can't use the blockGasLimit cause the next blocks could have a lower limit : https://github.com/ethereum/remix/issues/506
this
.
blockGasLimit
=
(
block
&&
block
.
gasLimit
)
?
Math
.
floor
(
block
.
gasLimit
-
(
5
*
block
.
gasLimit
)
/
1024
)
:
this
.
blockGasLimitDefault
}
else
{
this
.
blockGasLimit
=
this
.
blockGasLimitDefault
}
},
15000
)
}
})
}
}
// TODO: not used here anymore and needs to be moved
// TODO: not used here anymore and needs to be moved
...
@@ -218,6 +223,7 @@ function ExecutionContext () {
...
@@ -218,6 +223,7 @@ function ExecutionContext () {
}
}
if
(
web3
.
isConnected
())
{
if
(
web3
.
isConnected
())
{
executionContext
=
context
executionContext
=
context
self
.
_updateBlockGasLimit
()
self
.
event
.
trigger
(
'contextChanged'
,
[
'web3'
])
self
.
event
.
trigger
(
'contextChanged'
,
[
'web3'
])
self
.
event
.
trigger
(
'web3EndpointChanged'
)
self
.
event
.
trigger
(
'web3EndpointChanged'
)
cb
()
cb
()
...
...
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