Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ The process can be interrupted at any time (Ctrl+C), and it will attempt to save
}

cmd.Flags().Uint64VarP(&startBlock, "start", "", 31306381, "Start block (optional, uses contract start block if 0)")
cmd.Flags().Uint64VarP(&endBlock, "end", "", 39810670, "End block (optional, uses latest block if 0)")
cmd.Flags().StringVarP(&rpcEndpoint, "endpoint", "e", "https://wandering-evocative-gas.xdai.quiknode.pro/0f2525676e3ba76259ab3b72243f7f60334b0000/", "Ethereum RPC endpoint URL")
cmd.Flags().Uint64VarP(&endBlock, "end", "", 0, "End block (optional, uses latest block if 0)")
cmd.Flags().StringVarP(&rpcEndpoint, "endpoint", "e", "https://rpc.gnosis.gateway.fm", "Ethereum based RPC endpoint URL")
cmd.Flags().IntVarP(&maxRequest, "max-request", "m", 15, "Max RPC requests/sec")
cmd.Flags().Uint32VarP(&blockRangeLimit, "block-range-limit", "b", 5, "Max blocks per log query")
cmd.Flags().StringVarP(&outputFile, "output", "o", "export.ndjson", "Output file path (NDJSON)")
Expand Down
23 changes: 4 additions & 19 deletions pkg/eventfetcher/eventfetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,24 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethersphere/batch-export/pkg/ethclientwrapper"
"github.com/ethersphere/batch-export/pkg/logcache"
)

type Client struct {
validate *validator.Validate
client *ethclientwrapper.Client
logger log.Logger
blockRangeLimit uint32
logCache *logcache.Cache

batchCreatedTopic common.Hash
batchTopUpTopic common.Hash
batchDepthIncreaseTopic common.Hash
priceUpdateTopic common.Hash
pausedTopic common.Hash
// pausedTopic common.Hash
}

func NewClient(client *ethclientwrapper.Client, postageStampContractABI abi.ABI, blockRangeLimit uint32, logger log.Logger) *Client {
return &Client{
validate: validator.New(),
logCache: logcache.New(),
client: client,
logger: logger,
blockRangeLimit: blockRangeLimit,
Expand All @@ -59,14 +56,6 @@ func (c *Client) GetLogs(ctx context.Context, tr *Request) (<-chan types.Log, <-
go func() {
defer close(logChan)
defer close(errorChan)
// send the last cached value to the channel
// defer func() {
// priceUpdateLog := c.logCache.Get()
// if priceUpdateLog != nil {
// c.logger.Info("sending last cached value", "transactionHash", priceUpdateLog.TxHash)
// logChan <- *priceUpdateLog
// }
// }()

if err := c.validate.Struct(tr); err != nil {
errorChan <- fmt.Errorf("error validating request: %w", err)
Expand Down Expand Up @@ -97,6 +86,7 @@ func (c *Client) GetLogs(ctx context.Context, tr *Request) (<-chan types.Log, <-
errorChan <- fmt.Errorf("start block (%s) cannot be greater than end block (%s)", fromBlock.String(), toBlock.String())
return
}

query := c.filterQuery(tr.Address, fromBlock, toBlock)
c.fetchLogs(ctx, query, logChan, errorChan)
}()
Expand Down Expand Up @@ -136,16 +126,11 @@ func (c *Client) fetchLogs(ctx context.Context, query ethereum.FilterQuery, logs
}

for _, log := range logs {
// cache the price update log and skip sending it to the channel
// if log.Topics[0] == c.priceUpdateTopic {
// c.logCache.Set(&log)
// continue
// }
select {
case logsChan <- log:
case <-ctx.Done():
errorChan <- ctx.Err()
return // stop processing if context is cancelled
return
}
}

Expand Down Expand Up @@ -173,7 +158,7 @@ func (c *Client) filterQuery(postageStampContractAddress common.Address, from, t
c.batchTopUpTopic,
c.batchDepthIncreaseTopic,
c.priceUpdateTopic,
c.pausedTopic,
// c.pausedTopic,
},
},
}
Expand Down
28 changes: 0 additions & 28 deletions pkg/logcache/logcache.go

This file was deleted.

18 changes: 0 additions & 18 deletions pkg/logcache/logcache_test.go

This file was deleted.