forked from cerc-io/ipld-eth-server
Add an API to change addresses being watched by geth for direct indexing
This commit is contained in:
parent
f57b816530
commit
1a6ff273ba
@ -20,6 +20,7 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/ethereum/go-ethereum/statediff/types"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/vulcanize/ipld-eth-server/pkg/eth"
|
||||
@ -33,13 +34,15 @@ const APIVersion = "0.0.1"
|
||||
|
||||
// PublicServerAPI is the public api for the watcher
|
||||
type PublicServerAPI struct {
|
||||
w Server
|
||||
w Server
|
||||
rpc *rpc.Client
|
||||
}
|
||||
|
||||
// NewPublicServerAPI creates a new PublicServerAPI with the provided underlying Server process
|
||||
func NewPublicServerAPI(w Server) *PublicServerAPI {
|
||||
func NewPublicServerAPI(w Server, client *rpc.Client) *PublicServerAPI {
|
||||
return &PublicServerAPI{
|
||||
w: w,
|
||||
w: w,
|
||||
rpc: client,
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,3 +84,13 @@ func (api *PublicServerAPI) Stream(ctx context.Context, params eth.SubscriptionS
|
||||
|
||||
return rpcSub, nil
|
||||
}
|
||||
|
||||
// WatchAddress makes a geth WatchAddress API call with the given operation and args
|
||||
func (api *PublicServerAPI) WatchAddress(operation types.OperationType, args []types.WatchAddressArg) error {
|
||||
err := api.rpc.Call(nil, "statediff_watchAddress", operation, args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ func (sap *Service) APIs() []rpc.API {
|
||||
{
|
||||
Namespace: APIName,
|
||||
Version: APIVersion,
|
||||
Service: NewPublicServerAPI(sap),
|
||||
Service: NewPublicServerAPI(sap, sap.client),
|
||||
Public: true,
|
||||
},
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user