Igor Mandrigin 31cf2297d2 Implement block filters API for the RPC mode.
Some operations (like deploying contracts) require filter APIs to work.
Since these operations aren't supported on Infura anymore, and we don't
run LES, a separate implemenation of filters is required.

Signed-off-by: Igor Mandrigin <i@mandrigin.ru>
2018-05-08 19:46:25 +02:00

51 lines
1.2 KiB
Go

package rpcfilters
import (
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/rpc"
)
// Make sure that Service implements node.Service interface.
var _ node.Service = (*Service)(nil)
// Service represents out own implementation of personal sign operations.
type Service struct {
latestBlockChangedEvent *latestBlockChangedEvent
}
// New returns a new Service.
func New(rpc rpcProvider) *Service {
provider := &latestBlockProviderRPC{rpc}
event := newLatestBlockChangedEvent(provider)
return &Service{event}
}
// Protocols returns a new protocols list. In this case, there are none.
func (s *Service) Protocols() []p2p.Protocol {
return []p2p.Protocol{}
}
// APIs returns a list of new APIs.
func (s *Service) APIs() []rpc.API {
return []rpc.API{
{
Namespace: "eth",
Version: "1.0",
Service: NewPublicAPI(s.latestBlockChangedEvent),
Public: true,
},
}
}
// Start is run when a service is started.
func (s *Service) Start(server *p2p.Server) error {
return s.latestBlockChangedEvent.Start()
}
// Stop is run when a service is stopped.
func (s *Service) Stop() error {
s.latestBlockChangedEvent.Stop()
return nil
}