mirror of
https://github.com/status-im/status-go.git
synced 2025-01-22 04:31:30 +00:00
38308d48f2
* feat_: log error and stacktrace when panic in goroutine * test_: add test TestSafeGo * chore_: rename logAndCall to call * chore_: rename SafeGo to Go * chore_: make lint-fix * chore_: use t.Cleanup * chore_: Revert "chore_: use t.Cleanup" This reverts commit 4eb420d179cc0e208e84c13cb941e6b3d1ed9819. * chore_: Revert "chore_: make lint-fix" This reverts commit fcc995f157e671a4229b47419c3a0e4004b5fdab. * chore_: Revert "chore_: rename SafeGo to Go" This reverts commit a6d73d6df583f313032d79aac62f66328039cb55. * chore_: Revert "chore_: rename logAndCall to call" This reverts commit 8fbe993bedb9fbba67349a44f151e2dd5e3bc4cc. * chore_: Revert "test_: add test TestSafeGo" This reverts commit a1fa91839f3960398980c6bf456e6462ec944819. * chore_: Revert "feat_: log error and stacktrace when panic in goroutine" This reverts commit f612dd828fa2ce410d0e806fe773ecbe3e86a68a. * feat_: log error and stacktrace when panic in goroutine * chore_: make lint-fix * chore_: rename logAndCall to call * chore_: renaming LogOnPanic * chore_: update rest goroutine function calls * chore_: make lint-fix
78 lines
2.0 KiB
Go
78 lines
2.0 KiB
Go
package rpcfilters
|
|
|
|
import (
|
|
"github.com/ethereum/go-ethereum/node"
|
|
"github.com/ethereum/go-ethereum/p2p"
|
|
"github.com/ethereum/go-ethereum/rpc"
|
|
"github.com/status-im/status-go/common"
|
|
)
|
|
|
|
// Make sure that Service implements node.Lifecycle interface.
|
|
var _ node.Lifecycle = (*Service)(nil)
|
|
|
|
// Service represents out own implementation of personal sign operations.
|
|
type Service struct {
|
|
latestBlockChangedEvent *latestBlockChangedEvent
|
|
transactionSentToUpstreamEvent *transactionSentToUpstreamEvent
|
|
rpc rpcProvider
|
|
|
|
quit chan struct{}
|
|
}
|
|
|
|
// New returns a new Service.
|
|
func New(rpc rpcProvider) *Service {
|
|
provider := &latestBlockProviderRPC{rpc}
|
|
latestBlockChangedEvent := newLatestBlockChangedEvent(provider)
|
|
transactionSentToUpstreamEvent := newTransactionSentToUpstreamEvent()
|
|
return &Service{
|
|
latestBlockChangedEvent: latestBlockChangedEvent,
|
|
transactionSentToUpstreamEvent: transactionSentToUpstreamEvent,
|
|
|
|
rpc: rpc,
|
|
}
|
|
}
|
|
|
|
// 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),
|
|
Public: true,
|
|
},
|
|
}
|
|
}
|
|
|
|
// Start is run when a service is started.
|
|
func (s *Service) Start() error {
|
|
s.quit = make(chan struct{})
|
|
err := s.transactionSentToUpstreamEvent.Start()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return s.latestBlockChangedEvent.Start()
|
|
}
|
|
|
|
// Stop is run when a service is stopped.
|
|
func (s *Service) Stop() error {
|
|
close(s.quit)
|
|
s.transactionSentToUpstreamEvent.Stop()
|
|
s.latestBlockChangedEvent.Stop()
|
|
return nil
|
|
}
|
|
|
|
func (s *Service) TransactionSentToUpstreamEvent() ChainEvent {
|
|
return s.transactionSentToUpstreamEvent
|
|
}
|
|
|
|
func (s *Service) TriggerTransactionSentToUpstreamEvent(txInfo *PendingTxInfo) {
|
|
defer common.LogOnPanic()
|
|
s.transactionSentToUpstreamEvent.Trigger(txInfo)
|
|
}
|