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 (
"context"
"errors"
"fmt"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/rpc"
@ -11,6 +12,7 @@ import (
)
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)
if err != nil {
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) {
fmt.Printf(">>>>> GetVoteOnHash: %v\n", req)
vote, err := s.backend.APIBackend.GetVoteOnHash(ctx, req.StartBlockNumber, req.EndBlockNumber, req.Hash, req.MilestoneId)
if err != nil {
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) {
fmt.Printf(">>>>> GetHeaderByNumber: %v\n", req)
header, err := s.backend.APIBackend.HeaderByNumber(ctx, rpc.BlockNumber(req.Number))
if err != nil {
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) {
fmt.Printf(">>>>> GetBlockByNumber: %v\n", req)
block, err := s.backend.APIBackend.BlockByNumber(ctx, rpc.BlockNumber(req.Number))
if err != nil {
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) {
fmt.Printf(">>>>> GetTransactionReceipt: %v\n", req)
_, blockHash, _, txnIndex, err := s.backend.APIBackend.GetTransaction(ctx, protoutil.ConvertH256ToHash(req.Hash))
if err != nil {
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) {
fmt.Printf(">>>>> GetBorBlockReceipt: %v\n", req)
receipt, err := s.backend.APIBackend.GetBorBlockReceipt(ctx, protoutil.ConvertH256ToHash(req.Hash))
if err != nil {
return nil, err

View file

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