go-eth-proxy

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

service.go (683B)


      1 package geth
      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 
     14 type ProxyService struct {
     15 	store store.Store
     16 }
     17 
     18 func NewProxyService(store store.Store) (*ProxyService) {
     19 	return &ProxyService{
     20 		store: store,
     21 	}
     22 }
     23 
     24 func (p *ProxyService) GetTransactionByHash(ctx context.Context, hsh string) (*types.Transaction, error) {
     25 	tx := &types.Transaction{}
     26 
     27 	b := common.FromHex(hsh)
     28 	r, err := p.store.GetTransaction(b)
     29 
     30 	err = tx.UnmarshalJSON(r)
     31 	if err != nil {
     32 		return nil, err
     33 	}
     34 	log.Printf("tx %v gasprice %d gas %d", tx.Type(), tx.GasPrice(), tx.Gas())
     35 	return tx, nil
     36 }