Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
518dc87d
Commit
518dc87d
authored
Jul 02, 2015
by
zelig
Committed by
Jeffrey Wilcke
Jul 07, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix sleepBlocks, implement sleep
parent
6391ec0c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
19 deletions
+45
-19
registrar.go
common/registrar/registrar.go
+1
-1
admin.go
rpc/api/admin.go
+11
-9
admin_args.go
rpc/api/admin_args.go
+32
-8
admin_js.go
rpc/api/admin_js.go
+1
-1
No files found.
common/registrar/registrar.go
View file @
518dc87d
...
...
@@ -129,7 +129,7 @@ func (self *Registrar) SetHashReg(hashreg string, addr common.Address) (err erro
return
}
HashRegAddr
,
err
=
self
.
backend
.
Transact
(
addr
.
Hex
(),
""
,
""
,
""
,
"
200000
"
,
""
,
HashRegCode
)
HashRegAddr
,
err
=
self
.
backend
.
Transact
(
addr
.
Hex
(),
""
,
""
,
""
,
""
,
""
,
HashRegCode
)
if
err
!=
nil
{
err
=
fmt
.
Errorf
(
"HashReg address not found and sender for creation failed: %v"
,
err
)
}
...
...
rpc/api/admin.go
View file @
518dc87d
...
...
@@ -43,7 +43,6 @@ var (
"admin_datadir"
:
(
*
adminApi
)
.
DataDir
,
"admin_startRPC"
:
(
*
adminApi
)
.
StartRPC
,
"admin_stopRPC"
:
(
*
adminApi
)
.
StopRPC
,
"admin_sleepBlocks"
:
(
*
adminApi
)
.
SleepBlocks
,
"admin_setGlobalRegistrar"
:
(
*
adminApi
)
.
SetGlobalRegistrar
,
"admin_setHashReg"
:
(
*
adminApi
)
.
SetHashReg
,
"admin_setUrlHint"
:
(
*
adminApi
)
.
SetUrlHint
,
...
...
@@ -54,6 +53,8 @@ var (
"admin_stopNatSpec"
:
(
*
adminApi
)
.
StopNatSpec
,
"admin_getContractInfo"
:
(
*
adminApi
)
.
GetContractInfo
,
"admin_httpGet"
:
(
*
adminApi
)
.
HttpGet
,
"admin_sleepBlocks"
:
(
*
adminApi
)
.
SleepBlocks
,
"admin_sleep"
:
(
*
adminApi
)
.
Sleep
,
}
)
...
...
@@ -303,14 +304,15 @@ func sleepBlocks(wait chan *big.Int, height *big.Int, timer <-chan time.Time) (n
return
}
// sec, err := call.Argument(0).ToInteger()
// if err != nil {
// fmt.Println(err)
// return otto.FalseValue()
// }
// time.Sleep(time.Duration(sec) * time.Second)
// return otto.UndefinedValue()
// }
func
(
self
*
adminApi
)
Sleep
(
req
*
shared
.
Request
)
(
interface
{},
error
)
{
args
:=
new
(
SleepArgs
)
if
err
:=
self
.
coder
.
Decode
(
req
.
Params
,
&
args
);
err
!=
nil
{
return
nil
,
shared
.
NewDecodeParamError
(
err
.
Error
())
}
time
.
Sleep
(
time
.
Duration
(
args
.
S
)
*
time
.
Second
)
return
nil
,
nil
}
func
(
self
*
adminApi
)
SetGlobalRegistrar
(
req
*
shared
.
Request
)
(
interface
{},
error
)
{
args
:=
new
(
SetGlobalRegistrarArgs
)
if
err
:=
self
.
coder
.
Decode
(
req
.
Params
,
&
args
);
err
!=
nil
{
...
...
rpc/api/admin_args.go
View file @
518dc87d
...
...
@@ -149,6 +149,30 @@ func (args *StartRPCArgs) UnmarshalJSON(b []byte) (err error) {
return
nil
}
type
SleepArgs
struct
{
S
int
}
func
(
args
*
SleepArgs
)
UnmarshalJSON
(
b
[]
byte
)
(
err
error
)
{
var
obj
[]
interface
{}
if
err
:=
json
.
Unmarshal
(
b
,
&
obj
);
err
!=
nil
{
return
shared
.
NewDecodeParamError
(
err
.
Error
())
}
if
len
(
obj
)
>=
1
{
if
obj
[
0
]
!=
nil
{
if
n
,
err
:=
numString
(
obj
[
0
]);
err
==
nil
{
args
.
S
=
int
(
n
.
Int64
())
}
else
{
return
shared
.
NewInvalidTypeError
(
"N"
,
"not an integer: "
+
err
.
Error
())
}
}
else
{
return
shared
.
NewInsufficientParamsError
(
0
,
1
)
}
}
return
nil
}
type
SleepBlocksArgs
struct
{
N
int64
Timeout
int64
...
...
@@ -163,19 +187,19 @@ func (args *SleepBlocksArgs) UnmarshalJSON(b []byte) (err error) {
args
.
N
=
1
args
.
Timeout
=
0
if
len
(
obj
)
>=
1
{
if
n
,
ok
:=
obj
[
0
]
.
(
int64
);
ok
{
args
.
N
=
n
if
len
(
obj
)
>=
1
&&
obj
[
0
]
!=
nil
{
if
n
,
err
:=
numString
(
obj
[
0
]);
err
==
nil
{
args
.
N
=
n
.
Int64
()
}
else
{
return
shared
.
NewInvalidTypeError
(
"N"
,
"not an integer
"
)
return
shared
.
NewInvalidTypeError
(
"N"
,
"not an integer
: "
+
err
.
Error
()
)
}
}
if
len
(
obj
)
>=
2
{
if
n
,
ok
:=
obj
[
1
]
.
(
int64
);
ok
{
args
.
Timeout
=
n
if
len
(
obj
)
>=
2
&&
obj
[
1
]
!=
nil
{
if
n
,
err
:=
numString
(
obj
[
1
]);
err
==
nil
{
args
.
Timeout
=
n
.
Int64
()
}
else
{
return
shared
.
NewInvalidTypeError
(
"
N"
,
"not an integer"
)
return
shared
.
NewInvalidTypeError
(
"
Timeout"
,
"not an integer: "
+
err
.
Error
()
)
}
}
...
...
rpc/api/admin_js.go
View file @
518dc87d
...
...
@@ -57,7 +57,7 @@ web3._extend({
new web3._extend.Method({
name: 'stopRPC',
call: 'admin_stopRPC',
params:
0
,
params:
2
,
inputFormatter: [],
outputFormatter: web3._extend.formatters.formatOutputBool
}),
...
...
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