mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-04 01:54:28 +00:00
e4f495fa44
* it compiles * after recent master * fix linters warnings * grpcV7 * go mod tidy * unmarshall adresses or adress * fix linters * after cr * after cr * after cr * after cr * fix tests * remove dev version * it compiles * mod tidy * fix bin deps * use stable version of grpc * switch back to master constructor * switch back to master constructor * add a bit docs * add a bit docs Co-authored-by: Alexey Akhunov <akhounov@gmail.com> Co-authored-by: alex.sharov <AskAlexSharov@gmail.com>
65 lines
1.8 KiB
Go
65 lines
1.8 KiB
Go
package remotedbserver
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/ledgerwatch/turbo-geth/common"
|
|
"github.com/ledgerwatch/turbo-geth/core"
|
|
"github.com/ledgerwatch/turbo-geth/core/types"
|
|
"github.com/ledgerwatch/turbo-geth/ethdb/remote"
|
|
"github.com/ledgerwatch/turbo-geth/params"
|
|
"github.com/ledgerwatch/turbo-geth/rlp"
|
|
)
|
|
|
|
type EthBackendServer struct {
|
|
remote.UnimplementedETHBACKENDServer // must be embedded to have forward compatible implementations.
|
|
|
|
eth core.Backend
|
|
}
|
|
|
|
func NewEthBackendServer(eth core.Backend) *EthBackendServer {
|
|
return &EthBackendServer{eth: eth}
|
|
}
|
|
|
|
func (s *EthBackendServer) Add(_ context.Context, in *remote.TxRequest) (*remote.AddReply, error) {
|
|
signedTx := new(types.Transaction)
|
|
out := &remote.AddReply{Hash: common.Hash{}.Bytes()}
|
|
|
|
if err := rlp.DecodeBytes(in.Signedtx, signedTx); err != nil {
|
|
return out, err
|
|
}
|
|
|
|
if err := s.eth.TxPool().AddLocal(signedTx); err != nil {
|
|
return out, err
|
|
}
|
|
|
|
out.Hash = signedTx.Hash().Bytes()
|
|
return out, nil
|
|
}
|
|
|
|
func (s *EthBackendServer) Etherbase(_ context.Context, _ *remote.EtherbaseRequest) (*remote.EtherbaseReply, error) {
|
|
out := &remote.EtherbaseReply{Hash: common.Hash{}.Bytes()}
|
|
|
|
base, err := s.eth.Etherbase()
|
|
if err != nil {
|
|
return out, err
|
|
}
|
|
|
|
out.Hash = base.Hash().Bytes()
|
|
return out, nil
|
|
}
|
|
|
|
func (s *EthBackendServer) NetVersion(_ context.Context, _ *remote.NetVersionRequest) (*remote.NetVersionReply, error) {
|
|
id, err := s.eth.NetVersion()
|
|
if err != nil {
|
|
return &remote.NetVersionReply{}, err
|
|
}
|
|
return &remote.NetVersionReply{Id: id}, nil
|
|
}
|
|
|
|
func (s *EthBackendServer) BloomStatus(_ context.Context, _ *remote.BloomStatusRequest) (*remote.BloomStatusReply, error) {
|
|
sections, _, _ := s.eth.BloomIndexer().Sections()
|
|
|
|
return &remote.BloomStatusReply{Size: params.BloomBitsBlocks, Sections: sections}, nil
|
|
}
|