add: logs

This commit is contained in:
marcello33 2024-11-07 14:14:19 +01:00
parent 1918691cfa
commit 7b4666df92
No known key found for this signature in database
GPG key ID: 06128777E3C36B16
2 changed files with 13 additions and 0 deletions

View file

@ -3,6 +3,7 @@ package server
import ( import (
"context" "context"
"errors" "errors"
"fmt"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/rpc"
@ -11,6 +12,7 @@ import (
) )
func (s *Server) GetRootHash(ctx context.Context, req *protobor.GetRootHashRequest) (*protobor.GetRootHashResponse, error) { func (s *Server) GetRootHash(ctx context.Context, req *protobor.GetRootHashRequest) (*protobor.GetRootHashResponse, error) {
fmt.Printf(">>>>> GetRootHash: %v\n", req)
rootHash, err := s.backend.APIBackend.GetRootHash(ctx, req.StartBlockNumber, req.EndBlockNumber) rootHash, err := s.backend.APIBackend.GetRootHash(ctx, req.StartBlockNumber, req.EndBlockNumber)
if err != nil { if err != nil {
return nil, err return nil, err
@ -20,6 +22,7 @@ func (s *Server) GetRootHash(ctx context.Context, req *protobor.GetRootHashReque
} }
func (s *Server) GetVoteOnHash(ctx context.Context, req *protobor.GetVoteOnHashRequest) (*protobor.GetVoteOnHashResponse, error) { func (s *Server) GetVoteOnHash(ctx context.Context, req *protobor.GetVoteOnHashRequest) (*protobor.GetVoteOnHashResponse, error) {
fmt.Printf(">>>>> GetVoteOnHash: %v\n", req)
vote, err := s.backend.APIBackend.GetVoteOnHash(ctx, req.StartBlockNumber, req.EndBlockNumber, req.Hash, req.MilestoneId) vote, err := s.backend.APIBackend.GetVoteOnHash(ctx, req.StartBlockNumber, req.EndBlockNumber, req.Hash, req.MilestoneId)
if err != nil { if err != nil {
return nil, err return nil, err
@ -37,6 +40,7 @@ func headerToProtoborHeader(h *types.Header) *protobor.Header {
} }
func (s *Server) GetHeaderByNumber(ctx context.Context, req *protobor.GetHeaderByNumberRequest) (*protobor.GetHeaderByNumberResponse, error) { func (s *Server) GetHeaderByNumber(ctx context.Context, req *protobor.GetHeaderByNumberRequest) (*protobor.GetHeaderByNumberResponse, error) {
fmt.Printf(">>>>> GetHeaderByNumber: %v\n", req)
header, err := s.backend.APIBackend.HeaderByNumber(ctx, rpc.BlockNumber(req.Number)) header, err := s.backend.APIBackend.HeaderByNumber(ctx, rpc.BlockNumber(req.Number))
if err != nil { if err != nil {
return nil, err return nil, err
@ -46,6 +50,7 @@ func (s *Server) GetHeaderByNumber(ctx context.Context, req *protobor.GetHeaderB
} }
func (s *Server) GetBlockByNumber(ctx context.Context, req *protobor.GetBlockByNumberRequest) (*protobor.GetBlockByNumberResponse, error) { func (s *Server) GetBlockByNumber(ctx context.Context, req *protobor.GetBlockByNumberRequest) (*protobor.GetBlockByNumberResponse, error) {
fmt.Printf(">>>>> GetBlockByNumber: %v\n", req)
block, err := s.backend.APIBackend.BlockByNumber(ctx, rpc.BlockNumber(req.Number)) block, err := s.backend.APIBackend.BlockByNumber(ctx, rpc.BlockNumber(req.Number))
if err != nil { if err != nil {
return nil, err return nil, err
@ -61,6 +66,7 @@ func blockToProtoBlock(h *types.Block) *protobor.Block {
} }
func (s *Server) GetTransactionReceipt(ctx context.Context, req *protobor.ReceiptRequest) (*protobor.ReceiptResponse, error) { func (s *Server) GetTransactionReceipt(ctx context.Context, req *protobor.ReceiptRequest) (*protobor.ReceiptResponse, error) {
fmt.Printf(">>>>> GetTransactionReceipt: %v\n", req)
_, blockHash, _, txnIndex, err := s.backend.APIBackend.GetTransaction(ctx, protoutil.ConvertH256ToHash(req.Hash)) _, blockHash, _, txnIndex, err := s.backend.APIBackend.GetTransaction(ctx, protoutil.ConvertH256ToHash(req.Hash))
if err != nil { if err != nil {
return nil, err return nil, err
@ -83,6 +89,7 @@ func (s *Server) GetTransactionReceipt(ctx context.Context, req *protobor.Receip
} }
func (s *Server) GetBorBlockReceipt(ctx context.Context, req *protobor.ReceiptRequest) (*protobor.ReceiptResponse, error) { func (s *Server) GetBorBlockReceipt(ctx context.Context, req *protobor.ReceiptRequest) (*protobor.ReceiptResponse, error) {
fmt.Printf(">>>>> GetBorBlockReceipt: %v\n", req)
receipt, err := s.backend.APIBackend.GetBorBlockReceipt(ctx, protoutil.ConvertH256ToHash(req.Hash)) receipt, err := s.backend.APIBackend.GetBorBlockReceipt(ctx, protoutil.ConvertH256ToHash(req.Hash))
if err != nil { if err != nil {
return nil, err return nil, err

View file

@ -1,6 +1,7 @@
package server package server
import ( import (
"fmt"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/internal/cli/server/proto" "github.com/ethereum/go-ethereum/internal/cli/server/proto"
@ -12,6 +13,7 @@ import (
) )
func PeerInfoToPeer(info *p2p.PeerInfo) *proto.Peer { func PeerInfoToPeer(info *p2p.PeerInfo) *proto.Peer {
fmt.Printf(">>>>> PeerInfoToPeer: %v\n", info)
return &proto.Peer{ return &proto.Peer{
Id: info.ID, Id: info.ID,
Enode: info.Enode, Enode: info.Enode,
@ -24,12 +26,14 @@ func PeerInfoToPeer(info *p2p.PeerInfo) *proto.Peer {
} }
func ConvertBloomToProtoBloom(bloom types.Bloom) *protobor.Bloom { func ConvertBloomToProtoBloom(bloom types.Bloom) *protobor.Bloom {
fmt.Printf(">>>>> ConvertBloomToProtoBloom: %v\n", bloom)
return &protobor.Bloom{ return &protobor.Bloom{
Bloom: bloom.Bytes(), Bloom: bloom.Bytes(),
} }
} }
func ConvertLogsToProtoLogs(logs []*types.Log) []*protobor.Log { func ConvertLogsToProtoLogs(logs []*types.Log) []*protobor.Log {
fmt.Printf(">>>>> ConvertLogsToProtoLogs: %v\n", logs)
var protoLogs []*protobor.Log var protoLogs []*protobor.Log
for _, log := range logs { for _, log := range logs {
protoLog := &protobor.Log{ protoLog := &protobor.Log{
@ -50,6 +54,7 @@ func ConvertLogsToProtoLogs(logs []*types.Log) []*protobor.Log {
} }
func ConvertTopicsToProtoTopics(topics []common.Hash) []*protocommon.H256 { func ConvertTopicsToProtoTopics(topics []common.Hash) []*protocommon.H256 {
fmt.Printf(">>>>> ConvertTopicsToProtoTopics: %v\n", topics)
var protoTopics []*protocommon.H256 var protoTopics []*protocommon.H256
for _, topic := range topics { for _, topic := range topics {
protoTopics = append(protoTopics, protoutil.ConvertHashToH256(topic)) protoTopics = append(protoTopics, protoutil.ConvertHashToH256(topic))
@ -59,6 +64,7 @@ func ConvertTopicsToProtoTopics(topics []common.Hash) []*protocommon.H256 {
} }
func ConvertReceiptToProtoReceipt(receipt *types.Receipt) *protobor.Receipt { func ConvertReceiptToProtoReceipt(receipt *types.Receipt) *protobor.Receipt {
fmt.Printf(">>>>> ConvertReceiptToProtoReceipt: %v\n", receipt)
return &protobor.Receipt{ return &protobor.Receipt{
Type: uint64(receipt.Type), Type: uint64(receipt.Type),
PostState: receipt.PostState, PostState: receipt.PostState,