2020-07-25 17:18:18 +00:00
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ledgerwatch/turbo-geth/cmd/rpcdaemon/commands"
|
2020-08-11 21:09:30 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/core"
|
2020-07-25 17:18:18 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/ethdb"
|
|
|
|
"github.com/ledgerwatch/turbo-geth/node"
|
|
|
|
"github.com/ledgerwatch/turbo-geth/p2p"
|
|
|
|
"github.com/ledgerwatch/turbo-geth/rpc"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ node.Service = &RPCDaemonService{}
|
|
|
|
|
|
|
|
// RPCDaemonService is used in js console and console tests
|
|
|
|
type RPCDaemonService struct {
|
2020-08-11 21:09:30 +00:00
|
|
|
api []rpc.API
|
|
|
|
db *ethdb.ObjectDatabase
|
|
|
|
txpool *core.TxPool
|
2020-07-25 17:18:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (*RPCDaemonService) Protocols() []p2p.Protocol {
|
|
|
|
return []p2p.Protocol{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RPCDaemonService) Start(server *p2p.Server) error {
|
2020-08-11 21:09:30 +00:00
|
|
|
r.api = commands.GetAPI(r.db.KV(), core.RawFromTxPool(r.txpool), []string{"eth", "debug"})
|
2020-07-25 17:18:18 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RPCDaemonService) Stop() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RPCDaemonService) APIs() []rpc.API {
|
|
|
|
return r.api
|
|
|
|
}
|
|
|
|
|
2020-08-11 21:09:30 +00:00
|
|
|
func New(db *ethdb.ObjectDatabase, txpool *core.TxPool) *RPCDaemonService {
|
|
|
|
return &RPCDaemonService{[]rpc.API{}, db, txpool}
|
2020-07-25 17:18:18 +00:00
|
|
|
}
|