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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
github
maticnetwork
bor
Commits
a1c830cd
Commit
a1c830cd
authored
10 years ago
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
Defautl block
parent
49ded3aa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cmd/mist/assets/examples/info.html
+5
-2
5 additions, 2 deletions
cmd/mist/assets/examples/info.html
cmd/mist/assets/ext/ethereum.js/dist/ethereum.js
+452
-282
452 additions, 282 deletions
cmd/mist/assets/ext/ethereum.js/dist/ethereum.js
rpc/api.go
+31
-32
31 additions, 32 deletions
rpc/api.go
with
488 additions
and
316 deletions
cmd/mist/assets/examples/info.html
+
5
−
2
View file @
a1c830cd
...
...
@@ -62,6 +62,8 @@
web3
.
setProvider
(
new
web3
.
providers
.
HttpSyncProvider
(
'
http://localhost:8545
'
));
eth
.
defaultBlock
=
-
2
document
.
querySelector
(
"
#number
"
).
innerHTML
=
eth
.
number
;
document
.
querySelector
(
"
#coinbase
"
).
innerHTML
=
eth
.
coinbase
document
.
querySelector
(
"
#peer_count
"
).
innerHTML
=
eth
.
peerCount
;
...
...
@@ -72,8 +74,9 @@
document
.
querySelector
(
"
#mining
"
).
innerHTML
=
eth
.
mining
;
document
.
querySelector
(
"
#listening
"
).
innerHTML
=
eth
.
listening
;
eth
.
watch
(
'
chain
'
).
changed
(
function
()
{
document
.
querySelector
(
"
#number
"
).
innerHTML
=
eth
.
number
;
});
document
.
querySelector
(
"
#number
"
).
innerHTML
=
eth
.
number
;
});
</script>
...
...
This diff is collapsed.
Click to expand it.
cmd/mist/assets/ext/ethereum.js/dist/ethereum.js
+
452
−
282
View file @
a1c830cd
This diff is collapsed.
Click to expand it.
rpc/api.go
+
31
−
32
View file @
a1c830cd
...
...
@@ -52,19 +52,20 @@ type EthereumApi struct {
db
ethutil
.
Database
defaultBlockAge
int
defaultBlockAge
int
64
}
func
NewEthereumApi
(
eth
*
xeth
.
XEth
)
*
EthereumApi
{
db
,
_
:=
ethdb
.
NewLDBDatabase
(
"dapps"
)
api
:=
&
EthereumApi
{
eth
:
eth
,
mux
:
eth
.
Backend
()
.
EventMux
(),
quit
:
make
(
chan
struct
{}),
filterManager
:
filter
.
NewFilterManager
(
eth
.
Backend
()
.
EventMux
()),
logs
:
make
(
map
[
int
]
*
logFilter
),
messages
:
make
(
map
[
int
]
*
whisperFilter
),
db
:
db
,
eth
:
eth
,
mux
:
eth
.
Backend
()
.
EventMux
(),
quit
:
make
(
chan
struct
{}),
filterManager
:
filter
.
NewFilterManager
(
eth
.
Backend
()
.
EventMux
()),
logs
:
make
(
map
[
int
]
*
logFilter
),
messages
:
make
(
map
[
int
]
*
whisperFilter
),
db
:
db
,
defaultBlockAge
:
-
1
,
}
go
api
.
filterManager
.
Start
()
go
api
.
start
()
...
...
@@ -72,6 +73,22 @@ func NewEthereumApi(eth *xeth.XEth) *EthereumApi {
return
api
}
func
(
self
*
EthereumApi
)
setStateByBlockNumber
(
num
int64
)
{
chain
:=
self
.
xeth
()
.
Backend
()
.
ChainManager
()
var
block
*
types
.
Block
if
self
.
defaultBlockAge
<
0
{
num
=
chain
.
CurrentBlock
()
.
Number
()
.
Int64
()
+
num
+
1
}
block
=
chain
.
GetBlockByNumber
(
uint64
(
num
))
if
block
!=
nil
{
self
.
useState
(
state
.
New
(
block
.
Root
(),
self
.
xeth
()
.
Backend
()
.
Db
()))
}
else
{
self
.
useState
(
chain
.
State
())
}
}
func
(
self
*
EthereumApi
)
start
()
{
timer
:=
time
.
NewTicker
(
filterTickerTime
)
events
:=
self
.
mux
.
Subscribe
(
core
.
ChainEvent
{})
...
...
@@ -83,12 +100,7 @@ done:
switch
ev
.
(
type
)
{
case
core
.
ChainEvent
:
if
self
.
defaultBlockAge
<
0
{
chain
:=
self
.
xeth
()
.
Backend
()
.
ChainManager
()
block
:=
chain
.
GetBlockByNumber
(
chain
.
CurrentBlock
()
.
Number
()
.
Uint64
()
-
uint64
(
self
.
defaultBlockAge
))
if
block
!=
nil
{
statedb
:=
state
.
New
(
block
.
Root
(),
self
.
db
)
self
.
useState
(
statedb
)
}
self
.
setStateByBlockNumber
(
self
.
defaultBlockAge
)
}
}
case
<-
timer
.
C
:
...
...
@@ -239,21 +251,6 @@ func (p *EthereumApi) GetBlock(args *GetBlockArgs, reply *interface{}) error {
return
nil
}
/*
func unlockAccount(server, account *Account) bool {
pwd, status := server.PasswordDialog()
switch status {
case Ok:
if !account.Unlock([]byte(pwd)) {
return unlockAccount(account)
}
return true
default:
return false
}
}
*/
func
(
p
*
EthereumApi
)
Transact
(
args
*
NewTxArgs
,
reply
*
interface
{})
error
{
if
len
(
args
.
Gas
)
==
0
{
args
.
Gas
=
defaultGas
.
String
()
...
...
@@ -378,8 +375,10 @@ func (p *EthereumApi) GetDefaultBlockAge(reply *interface{}) error {
return
nil
}
func
(
p
*
EthereumApi
)
SetDefaultBlockAge
(
defaultBlockAge
int
,
reply
*
interface
{})
error
{
func
(
p
*
EthereumApi
)
SetDefaultBlockAge
(
defaultBlockAge
int
64
,
reply
*
interface
{})
error
{
p
.
defaultBlockAge
=
defaultBlockAge
p
.
setStateByBlockNumber
(
p
.
defaultBlockAge
)
*
reply
=
true
return
nil
}
...
...
@@ -531,7 +530,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
if
err
!=
nil
{
return
err
}
return
p
.
SetDefaultBlockAge
(
args
,
reply
)
return
p
.
SetDefaultBlockAge
(
int64
(
args
)
,
reply
)
case
"eth_peerCount"
:
return
p
.
GetPeerCount
(
reply
)
case
"eth_number"
:
...
...
@@ -720,7 +719,7 @@ func (self *EthereumApi) useState(statedb *state.StateDB) {
self
.
xethMu
.
Lock
()
defer
self
.
xethMu
.
Unlock
()
self
.
eth
=
self
.
x
eth
()
.
UseState
(
statedb
)
self
.
eth
=
self
.
eth
.
UseState
(
statedb
)
}
func
t
(
f
ui
.
Frontend
)
{
...
...
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