diff options
author | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-06-24 01:19:33 +0800 |
---|---|---|
committer | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-06-24 01:19:33 +0800 |
commit | 72e2613a9fe3205fa5a67b72b832e03b2357ee88 (patch) | |
tree | bbc987510d279d9e174ff8f684158d668131661e /rpc/api/admin_args.go | |
parent | 5daf8729be88eca87b302ebf7a46fc69cad0f6d0 (diff) | |
parent | 67e6f74e9af00ff011a6a02f18644804eb18cdaa (diff) | |
download | go-tangerine-72e2613a9fe3205fa5a67b72b832e03b2357ee88.tar go-tangerine-72e2613a9fe3205fa5a67b72b832e03b2357ee88.tar.gz go-tangerine-72e2613a9fe3205fa5a67b72b832e03b2357ee88.tar.bz2 go-tangerine-72e2613a9fe3205fa5a67b72b832e03b2357ee88.tar.lz go-tangerine-72e2613a9fe3205fa5a67b72b832e03b2357ee88.tar.xz go-tangerine-72e2613a9fe3205fa5a67b72b832e03b2357ee88.tar.zst go-tangerine-72e2613a9fe3205fa5a67b72b832e03b2357ee88.zip |
Merge branch 'release/0.9.32'v0.9.32
Diffstat (limited to 'rpc/api/admin_args.go')
-rw-r--r-- | rpc/api/admin_args.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/rpc/api/admin_args.go b/rpc/api/admin_args.go index 56bb57e20..5437971ca 100644 --- a/rpc/api/admin_args.go +++ b/rpc/api/admin_args.go @@ -95,3 +95,55 @@ func (args *SetSolcArgs) UnmarshalJSON(b []byte) (err error) { return shared.NewInvalidTypeError("path", "not a string") } + +type StartRPCArgs struct { + ListenAddress string + ListenPort uint + CorsDomain string + Apis string +} + +func (args *StartRPCArgs) UnmarshalJSON(b []byte) (err error) { + var obj []interface{} + if err := json.Unmarshal(b, &obj); err != nil { + return shared.NewDecodeParamError(err.Error()) + } + + args.ListenAddress = "127.0.0.1" + args.ListenPort = 8545 + args.Apis = "net,eth,web3" + + if len(obj) >= 1 { + if addr, ok := obj[0].(string); ok { + args.ListenAddress = addr + } else { + return shared.NewInvalidTypeError("listenAddress", "not a string") + } + } + + if len(obj) >= 2 { + if port, ok := obj[1].(float64); ok && port >= 0 && port <= 64*1024 { + args.ListenPort = uint(port) + } else { + return shared.NewInvalidTypeError("listenPort", "not a valid port number") + } + } + + if len(obj) >= 3 { + if corsDomain, ok := obj[2].(string); ok { + args.CorsDomain = corsDomain + } else { + return shared.NewInvalidTypeError("corsDomain", "not a string") + } + } + + if len(obj) >= 4 { + if apis, ok := obj[3].(string); ok { + args.Apis = apis + } else { + return shared.NewInvalidTypeError("apis", "not a string") + } + } + + return nil +} |