go-eth-proxy

Transparent proxy server for eth-cache
Info | Log | Files | Refs

service.go (586B)


      1 package proxy
      2 
      3 import (
      4 	"context"
      5 	"log"
      6 
      7 	"github.com/ethereum/go-ethereum/core/types"
      8 	"github.com/ethereum/go-ethereum/common"
      9 
     10 	"defalsify.org/go-eth-proxy/store"
     11 )
     12 
     13 type ProxyService struct {
     14 	store store.Store
     15 }
     16 
     17 func NewProxyService(store store.Store) (*ProxyService) {
     18 	return &ProxyService{
     19 		store: store,
     20 	}
     21 }
     22 
     23 func (p *ProxyService) GetTransactionByHash(ctx context.Context, hsh string) (*types.Transaction, error) {
     24 	log.Printf("get tx hash %s", hsh)
     25 	b := common.FromHex(hsh)
     26 	tx, err := p.store.GetTransaction(b)
     27 	if err != nil {
     28 		return nil, err
     29 	}
     30 
     31 	return tx, nil
     32 }