aboutsummaryrefslogtreecommitdiff
path: root/coreth.go
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2019-09-23 15:49:18 -0400
committerDeterminant <[email protected]>2019-09-23 15:49:18 -0400
commit215fec775fc457fb69d77fd0fc128893721fa34e (patch)
tree166d84b899039119fcbfbb61e64aba6af4836d62 /coreth.go
parent99c2de7c0df891080919d4da9caeda9b11718e4f (diff)
expose JSON-RPC interface
Diffstat (limited to 'coreth.go')
-rw-r--r--coreth.go17
1 files changed, 17 insertions, 0 deletions
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