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
f87501b1
Commit
f87501b1
authored
Jun 19, 2015
by
Bas van Kervel
Committed by
Bas van Kervel
Jun 22, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added batch support to console and attach actions
parent
3ff272b6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
30 deletions
+62
-30
js.go
cmd/geth/js.go
+19
-0
main.go
cmd/geth/main.go
+13
-4
flags.go
cmd/utils/flags.go
+4
-0
api_test.go
rpc/api/api_test.go
+8
-7
eth.go
rpc/api/eth.go
+0
-1
eth_args.go
rpc/api/eth_args.go
+18
-18
No files found.
cmd/geth/js.go
View file @
f87501b1
...
...
@@ -220,6 +220,25 @@ func (self *jsre) loadAutoCompletion() {
}
}
func
(
self
*
jsre
)
batch
(
statement
string
)
{
val
,
err
:=
self
.
re
.
Run
(
statement
)
if
err
!=
nil
{
fmt
.
Printf
(
"error: %v"
,
err
)
}
else
if
val
.
IsDefined
()
&&
val
.
IsObject
()
{
obj
,
_
:=
self
.
re
.
Get
(
"ret_result"
)
fmt
.
Printf
(
"%v"
,
obj
)
}
else
if
val
.
IsDefined
()
{
fmt
.
Printf
(
"%v"
,
val
)
}
if
self
.
atexit
!=
nil
{
self
.
atexit
()
}
self
.
re
.
Stop
(
false
)
}
// show summary of current geth instance
func
(
self
*
jsre
)
welcome
()
{
self
.
re
.
Eval
(
`console.log('instance: ' + web3.version.client);`
)
...
...
cmd/geth/main.go
View file @
f87501b1
...
...
@@ -255,6 +255,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
utils
.
IPCDisabledFlag
,
utils
.
IPCApiFlag
,
utils
.
IPCPathFlag
,
utils
.
ExecFlag
,
utils
.
WhisperEnabledFlag
,
utils
.
VMDebugFlag
,
utils
.
ProtocolVersionFlag
,
...
...
@@ -337,8 +338,12 @@ func attach(ctx *cli.Context) {
true
,
nil
)
repl
.
welcome
()
repl
.
interactive
()
if
ctx
.
GlobalString
(
utils
.
ExecFlag
.
Name
)
!=
""
{
repl
.
batch
(
ctx
.
GlobalString
(
utils
.
ExecFlag
.
Name
))
}
else
{
repl
.
welcome
()
repl
.
interactive
()
}
}
func
console
(
ctx
*
cli
.
Context
)
{
...
...
@@ -368,8 +373,12 @@ func console(ctx *cli.Context) {
nil
,
)
repl
.
welcome
()
repl
.
interactive
()
if
ctx
.
GlobalString
(
utils
.
ExecFlag
.
Name
)
!=
""
{
repl
.
batch
(
ctx
.
GlobalString
(
utils
.
ExecFlag
.
Name
))
}
else
{
repl
.
welcome
()
repl
.
interactive
()
}
ethereum
.
Stop
()
ethereum
.
WaitForShutdown
()
...
...
cmd/utils/flags.go
View file @
f87501b1
...
...
@@ -227,6 +227,10 @@ var (
Usage
:
"Filename for IPC socket/pipe"
,
Value
:
DirectoryString
{
common
.
DefaultIpcPath
()},
}
ExecFlag
=
cli
.
StringFlag
{
Name
:
"exec"
,
Usage
:
"Execute javascript statement (only in combination with console/attach)"
,
}
// Network Settings
MaxPeersFlag
=
cli
.
IntFlag
{
Name
:
"maxpeers"
,
...
...
rpc/api/api_test.go
View file @
f87501b1
...
...
@@ -3,12 +3,13 @@ package api
import
(
"testing"
"github.com/ethereum/go-ethereum/rpc/codec"
"encoding/json"
"strconv"
"github.com/ethereum/go-ethereum/common/compiler"
"github.com/ethereum/go-ethereum/rpc/shared"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/rpc/codec"
"github.com/ethereum/go-ethereum/rpc/shared"
"github.com/ethereum/go-ethereum/xeth"
)
...
...
@@ -58,11 +59,11 @@ func TestCompileSolidity(t *testing.T) {
t
.
Skip
(
"WARNING: skipping test because of solc different version (%v, test written for %v, may need to update)"
,
solc
.
Version
(),
solcVersion
)
}
source
:=
`contract test {\n`
+
" /// @notice Will multiply `a` by 7."
+
`\n`
+
` function multiply(uint a) returns(uint d) {\n`
+
` return a * 7;\n`
+
` }\n`
+
`}\n`
" /// @notice Will multiply `a` by 7."
+
`\n`
+
` function multiply(uint a) returns(uint d) {\n`
+
` return a * 7;\n`
+
` }\n`
+
`}\n`
jsonstr
:=
`{"jsonrpc":"2.0","method":"eth_compileSolidity","params":["`
+
source
+
`"],"id":64}`
...
...
rpc/api/eth.go
View file @
f87501b1
...
...
@@ -250,7 +250,6 @@ func (self *ethApi) Sign(req *shared.Request) (interface{}, error) {
return
v
,
nil
}
func
(
self
*
ethApi
)
PushTx
(
req
*
shared
.
Request
)
(
interface
{},
error
)
{
args
:=
new
(
NewDataArgs
)
if
err
:=
self
.
codec
.
Decode
(
req
.
Params
,
&
args
);
err
!=
nil
{
...
...
rpc/api/eth_args.go
View file @
f87501b1
...
...
@@ -227,32 +227,32 @@ func (args *GetDataArgs) UnmarshalJSON(b []byte) (err error) {
}
type
NewDataArgs
struct
{
Data
string
Data
string
}
func
(
args
*
NewDataArgs
)
UnmarshalJSON
(
b
[]
byte
)
(
err
error
)
{
var
obj
[]
interface
{}
var
obj
[]
interface
{}
if
err
:=
json
.
Unmarshal
(
b
,
&
obj
);
err
!=
nil
{
return
shared
.
NewDecodeParamError
(
err
.
Error
())
}
if
err
:=
json
.
Unmarshal
(
b
,
&
obj
);
err
!=
nil
{
return
shared
.
NewDecodeParamError
(
err
.
Error
())
}
// Check for sufficient params
if
len
(
obj
)
<
1
{
return
shared
.
NewInsufficientParamsError
(
len
(
obj
),
1
)
}
// Check for sufficient params
if
len
(
obj
)
<
1
{
return
shared
.
NewInsufficientParamsError
(
len
(
obj
),
1
)
}
data
,
ok
:=
obj
[
0
]
.
(
string
)
if
!
ok
{
return
shared
.
NewInvalidTypeError
(
"data"
,
"not a string"
)
}
args
.
Data
=
data
data
,
ok
:=
obj
[
0
]
.
(
string
)
if
!
ok
{
return
shared
.
NewInvalidTypeError
(
"data"
,
"not a string"
)
}
args
.
Data
=
data
if
len
(
args
.
Data
)
==
0
{
return
shared
.
NewValidationError
(
"data"
,
"is required"
)
}
if
len
(
args
.
Data
)
==
0
{
return
shared
.
NewValidationError
(
"data"
,
"is required"
)
}
return
nil
return
nil
}
type
NewSigArgs
struct
{
...
...
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