aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-01-29 01:14:28 +0800
committerobscuren <geffobscura@gmail.com>2015-01-29 01:14:28 +0800
commit7f638f0b2d8d989be25e660178d79df3278e4c84 (patch)
tree85c74ca9ca6c604df04e13c9d90d8af15b99e8d6 /rpc
parentb46e1ca97e61ebfe4c37961e723142245efe5016 (diff)
downloadgo-tangerine-7f638f0b2d8d989be25e660178d79df3278e4c84.tar.gz
go-tangerine-7f638f0b2d8d989be25e660178d79df3278e4c84.tar.zst
go-tangerine-7f638f0b2d8d989be25e660178d79df3278e4c84.zip
moving to a better xeth
Diffstat (limited to 'rpc')
-rw-r--r--rpc/http/server.go2
-rw-r--r--rpc/packages.go35
2 files changed, 17 insertions, 20 deletions
diff --git a/rpc/http/server.go b/rpc/http/server.go
index 93b52a634..2a492f465 100644
--- a/rpc/http/server.go
+++ b/rpc/http/server.go
@@ -85,6 +85,8 @@ func (s *RpcHttpServer) Start() {
func (s *RpcHttpServer) apiHandler(api *rpc.EthereumApi) http.Handler {
fn := func(w http.ResponseWriter, req *http.Request) {
+ w.Header().Set("Access-Control-Allow-Origin", "*")
+
rpchttplogger.Debugln("Handling request")
reqParsed, reqerr := JSON.ParseRequestBody(req)
diff --git a/rpc/packages.go b/rpc/packages.go
index 8b5965069..e6d4859d2 100644
--- a/rpc/packages.go
+++ b/rpc/packages.go
@@ -39,11 +39,11 @@ type RpcServer interface {
}
func NewEthereumApi(xeth *xeth.JSXEth) *EthereumApi {
- return &EthereumApi{pipe: xeth}
+ return &EthereumApi{xeth: xeth}
}
type EthereumApi struct {
- pipe *xeth.JSXEth
+ xeth *xeth.JSXEth
}
func (p *EthereumApi) GetBlock(args *GetBlockArgs, reply *interface{}) error {
@@ -53,9 +53,9 @@ func (p *EthereumApi) GetBlock(args *GetBlockArgs, reply *interface{}) error {
}
if args.BlockNumber > 0 {
- *reply = p.pipe.BlockByNumber(args.BlockNumber)
+ *reply = p.xeth.BlockByNumber(args.BlockNumber)
} else {
- *reply = p.pipe.BlockByHash(args.Hash)
+ *reply = p.xeth.BlockByHash(args.Hash)
}
return nil
}
@@ -65,7 +65,7 @@ func (p *EthereumApi) Transact(args *NewTxArgs, reply *interface{}) error {
if err != nil {
return err
}
- result, _ := p.pipe.Transact(p.pipe.Key().PrivateKey, args.Recipient, args.Value, args.Gas, args.GasPrice, args.Body)
+ result, _ := p.xeth.Transact( /* TODO specify account */ "", args.Recipient, args.Value, args.Gas, args.GasPrice, args.Body)
*reply = result
return nil
}
@@ -76,7 +76,7 @@ func (p *EthereumApi) Create(args *NewTxArgs, reply *interface{}) error {
return err
}
- result, _ := p.pipe.Transact(p.pipe.Key().PrivateKey, "", args.Value, args.Gas, args.GasPrice, args.Body)
+ result, _ := p.xeth.Transact( /* TODO specify account */ "", "", args.Value, args.Gas, args.GasPrice, args.Body)
*reply = result
return nil
}
@@ -86,23 +86,18 @@ func (p *EthereumApi) PushTx(args *PushTxArgs, reply *interface{}) error {
if err != nil {
return err
}
- result, _ := p.pipe.PushTx(args.Tx)
+ result, _ := p.xeth.PushTx(args.Tx)
*reply = result
return nil
}
-func (p *EthereumApi) GetKey(args interface{}, reply *interface{}) error {
- *reply = p.pipe.Key()
- return nil
-}
-
func (p *EthereumApi) GetStorageAt(args *GetStorageArgs, reply *interface{}) error {
err := args.requirements()
if err != nil {
return err
}
- state := p.pipe.World().SafeGet(ethutil.Hex2Bytes(args.Address))
+ state := p.xeth.State().SafeGet(args.Address)
var hx string
if strings.Index(args.Key, "0x") == 0 {
@@ -119,22 +114,22 @@ func (p *EthereumApi) GetStorageAt(args *GetStorageArgs, reply *interface{}) err
}
func (p *EthereumApi) GetPeerCount(reply *interface{}) error {
- *reply = p.pipe.PeerCount()
+ *reply = p.xeth.PeerCount()
return nil
}
func (p *EthereumApi) GetIsListening(reply *interface{}) error {
- *reply = p.pipe.IsListening()
+ *reply = p.xeth.IsListening()
return nil
}
func (p *EthereumApi) GetCoinbase(reply *interface{}) error {
- *reply = p.pipe.CoinBase()
+ *reply = p.xeth.Coinbase()
return nil
}
func (p *EthereumApi) GetIsMining(reply *interface{}) error {
- *reply = p.pipe.IsMining()
+ *reply = p.xeth.IsMining()
return nil
}
@@ -143,7 +138,7 @@ func (p *EthereumApi) GetTxCountAt(args *GetTxCountArgs, reply *interface{}) err
if err != nil {
return err
}
- *reply = p.pipe.TxCountAt(args.Address)
+ *reply = p.xeth.TxCountAt(args.Address)
return nil
}
@@ -152,7 +147,7 @@ func (p *EthereumApi) GetBalanceAt(args *GetBalanceArgs, reply *interface{}) err
if err != nil {
return err
}
- state := p.pipe.World().SafeGet(ethutil.Hex2Bytes(args.Address))
+ state := p.xeth.State().SafeGet(args.Address)
*reply = BalanceRes{Balance: state.Balance().String(), Address: args.Address}
return nil
}
@@ -162,7 +157,7 @@ func (p *EthereumApi) GetCodeAt(args *GetCodeAtArgs, reply *interface{}) error {
if err != nil {
return err
}
- *reply = p.pipe.CodeAt(args.Address)
+ *reply = p.xeth.CodeAt(args.Address)
return nil
}