diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-06-23 22:44:03 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-06-23 22:44:03 +0800 |
commit | 6b5532ab0d0e88f27af539840c58cbd6de13de90 (patch) | |
tree | 84f1856e1b3fb2fd927e6ef9c59983e4fb347a8c /rpc/api/admin_args.go | |
parent | 139439dcdc14e448bfdbd509bb135faa92337a28 (diff) | |
parent | 2b3957f3737b56622e38425a52caea2a836f8b63 (diff) | |
download | go-tangerine-6b5532ab0d0e88f27af539840c58cbd6de13de90.tar go-tangerine-6b5532ab0d0e88f27af539840c58cbd6de13de90.tar.gz go-tangerine-6b5532ab0d0e88f27af539840c58cbd6de13de90.tar.bz2 go-tangerine-6b5532ab0d0e88f27af539840c58cbd6de13de90.tar.lz go-tangerine-6b5532ab0d0e88f27af539840c58cbd6de13de90.tar.xz go-tangerine-6b5532ab0d0e88f27af539840c58cbd6de13de90.tar.zst go-tangerine-6b5532ab0d0e88f27af539840c58cbd6de13de90.zip |
Merge pull request #1279 from bas-vk/rpc-http
Integrate console and remove old rpc package structure
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 +} |