From 215fec775fc457fb69d77fd0fc128893721fa34e Mon Sep 17 00:00:00 2001 From: Determinant Date: Mon, 23 Sep 2019 15:49:18 -0400 Subject: expose JSON-RPC interface --- coreth.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/coreth.go b/coreth.go index c4cbf09..0dbb226 100644 --- a/coreth.go +++ b/coreth.go @@ -15,6 +15,7 @@ import ( "github.com/ava-labs/go-ethereum/crypto" "github.com/ava-labs/go-ethereum/event" "github.com/ava-labs/go-ethereum/log" + "github.com/ava-labs/go-ethereum/rpc" "github.com/mattn/go-isatty" ) @@ -134,6 +135,22 @@ func (self *ETHChain) InsertChain(chain []*types.Block) (int, error) { return self.backend.BlockChain().InsertChain(chain) } +func (self *ETHChain) NewRPCHandler() *rpc.Server { + return rpc.NewServer() +} + +func (self *ETHChain) AttachEthService(handler *rpc.Server, namespaces []string) { + nsmap := make(map[string]bool) + for _, ns := range namespaces { + nsmap[ns] = true + } + for _, api := range self.backend.APIs() { + if nsmap[api.Namespace] { + handler.RegisterName(api.Namespace, api.Service) + } + } +} + type Key struct { Address common.Address PrivateKey *ecdsa.PrivateKey -- cgit v1.2.3-70-g09d2