[WIP] Add a service to fill indexing gap for watched addresses #135

Closed
prathamesh0 wants to merge 16 commits from pm-watched-addresses into master
2 changed files with 20 additions and 4 deletions
Showing only changes of commit f190404ab5 - Show all commits

View File

@ -18,9 +18,12 @@ package serve
import (
"context"
"encoding/json"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/statediff"
"github.com/ethereum/go-ethereum/statediff/indexer/shared"
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
log "github.com/sirupsen/logrus"
"github.com/vulcanize/ipld-eth-server/pkg/eth"
@ -35,12 +38,14 @@ const APIVersion = "0.0.1"
// PublicServerAPI is the public api for the watcher
type PublicServerAPI struct {
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,
rpc: client,
}
}
@ -87,3 +92,14 @@ func (api *PublicServerAPI) Stream(ctx context.Context, params eth.SubscriptionS
func (api *PublicServerAPI) Chain() shared.ChainType {
return shared.Ethereum
}
// WatchAddress makes a geth WatchAddress API call with the given operation and args
func (api *PublicServerAPI) WatchAddress(operation statediff.OperationType, args []sdtypes.WatchAddressArg) error {
var data json.RawMessage
err := api.rpc.Call(&data, "statediff_watchAddress", operation, args)
if err != nil {
return err
}
return nil
}

View File

@ -126,7 +126,7 @@ func (sap *Service) APIs() []rpc.API {
{
Namespace: APIName,
Version: APIVersion,
Service: NewPublicServerAPI(sap),
Service: NewPublicServerAPI(sap, sap.client),
Public: true,
},
{