aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaran <maran.hidskes@gmail.com>2014-05-05 19:49:59 +0800
committerMaran <maran.hidskes@gmail.com>2014-05-05 19:49:59 +0800
commitc496aad20bebdeea240ee4b6cc8730d484240ca8 (patch)
tree70c55c7cc679ef8e6dd0a10f7a784eab0d7e8b41
parent8adad0654a46e4cad925a14f1c238081958558df (diff)
downloadgo-tangerine-c496aad20bebdeea240ee4b6cc8730d484240ca8.tar
go-tangerine-c496aad20bebdeea240ee4b6cc8730d484240ca8.tar.gz
go-tangerine-c496aad20bebdeea240ee4b6cc8730d484240ca8.tar.bz2
go-tangerine-c496aad20bebdeea240ee4b6cc8730d484240ca8.tar.lz
go-tangerine-c496aad20bebdeea240ee4b6cc8730d484240ca8.tar.xz
go-tangerine-c496aad20bebdeea240ee4b6cc8730d484240ca8.tar.zst
go-tangerine-c496aad20bebdeea240ee4b6cc8730d484240ca8.zip
Renamed Ethereum RPC package
-rw-r--r--etherpc/packages.go25
-rw-r--r--etherpc/server.go2
2 files changed, 17 insertions, 10 deletions
diff --git a/etherpc/packages.go b/etherpc/packages.go
index 85306d3d7..5074b0219 100644
--- a/etherpc/packages.go
+++ b/etherpc/packages.go
@@ -7,7 +7,7 @@ import (
_ "log"
)
-type MainPackage struct {
+type EthereumApi struct {
ethp *ethpub.PEthereum
}
@@ -65,7 +65,7 @@ func (b *GetBlockArgs) requirements() error {
return nil
}
-func (p *MainPackage) GetBlock(args *GetBlockArgs, reply *string) error {
+func (p *EthereumApi) GetBlock(args *GetBlockArgs, reply *string) error {
err := args.requirements()
if err != nil {
return err
@@ -121,7 +121,7 @@ func (a *NewTxArgs) requirementsContract() error {
return nil
}
-func (p *MainPackage) Transact(args *NewTxArgs, reply *string) error {
+func (p *EthereumApi) Transact(args *NewTxArgs, reply *string) error {
err := args.requirements()
if err != nil {
return err
@@ -131,7 +131,7 @@ func (p *MainPackage) Transact(args *NewTxArgs, reply *string) error {
return nil
}
-func (p *MainPackage) Create(args *NewTxArgs, reply *string) error {
+func (p *EthereumApi) Create(args *NewTxArgs, reply *string) error {
err := args.requirementsContract()
if err != nil {
return err
@@ -141,7 +141,7 @@ func (p *MainPackage) Create(args *NewTxArgs, reply *string) error {
return nil
}
-func (p *MainPackage) GetKey(args interface{}, reply *string) error {
+func (p *EthereumApi) GetKey(args interface{}, reply *string) error {
*reply = NewSuccessRes(p.ethp.GetKey())
return nil
}
@@ -167,14 +167,14 @@ type GetStorageAtRes struct {
Address string `json:"address"`
}
-func (p *MainPackage) GetStorageAt(args *GetStorageArgs, reply *string) error {
+func (p *EthereumApi) GetStorageAt(args *GetStorageArgs, reply *string) error {
err := args.requirements()
if err != nil {
return err
}
state := p.ethp.GetStateObject(args.Address)
value := state.GetStorage(args.Key)
- *reply = NewSuccessRes(&GetStorageAtRes{Address: args.Address, Key: args.Key, Value: value})
+ *reply = NewSuccessRes(GetStorageAtRes{Address: args.Address, Key: args.Key, Value: value})
return nil
}
@@ -189,11 +189,18 @@ func (a *GetBalanceArgs) requirements() error {
return nil
}
-func (p *MainPackage) GetBalanceAt(args *GetBalanceArgs, reply *string) error {
+type BalanceRes struct {
+ Balance string `json:"balance"`
+ Address string `json:"address"`
+}
+
+func (p *EthereumApi) GetBalanceAt(args *GetBalanceArgs, reply *string) error {
err := args.requirements()
if err != nil {
return err
}
+ state := p.ethp.GetStateObject(args.Address)
+ *reply = NewSuccessRes(BalanceRes{Balance: state.Value(), Address: args.Address})
return nil
}
@@ -202,7 +209,7 @@ type TestRes struct {
Answer int `json:"answer"`
}
-func (p *MainPackage) Test(args *GetBlockArgs, reply *string) error {
+func (p *EthereumApi) Test(args *GetBlockArgs, reply *string) error {
*reply = NewSuccessRes(TestRes{Answer: 15})
return nil
}
diff --git a/etherpc/server.go b/etherpc/server.go
index 7929563cb..49b4604cc 100644
--- a/etherpc/server.go
+++ b/etherpc/server.go
@@ -34,7 +34,7 @@ func (s *JsonRpcServer) Stop() {
func (s *JsonRpcServer) Start() {
ethutil.Config.Log.Infoln("[JSON] Starting JSON-RPC server")
go s.exitHandler()
- rpc.Register(&MainPackage{ethp: s.ethp})
+ rpc.Register(&EthereumApi{ethp: s.ethp})
rpc.HandleHTTP()
for {