diff options
author | Determinant <[email protected]> | 2019-09-23 15:49:18 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2019-09-23 15:49:18 -0400 |
commit | 215fec775fc457fb69d77fd0fc128893721fa34e (patch) | |
tree | 166d84b899039119fcbfbb61e64aba6af4836d62 /coreth.go | |
parent | 99c2de7c0df891080919d4da9caeda9b11718e4f (diff) |
expose JSON-RPC interface
Diffstat (limited to 'coreth.go')
-rw-r--r-- | coreth.go | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -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 |