Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/improve rpc client package #3111

Merged
merged 40 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
b811bf9
Renames GetVersion to GetClientVersion
tjayrush Jul 31, 2023
aee348d
Renames BlockNumber to GetLatestBlockNumber
tjayrush Jul 31, 2023
4fcce07
Merge branch 'feature/removes-node-package' into feature/improve-rpcC…
tjayrush Jul 31, 2023
f6f6f86
Renames GetBlockByNumber to GetBlockHeaderByNumber (the hashes only v…
tjayrush Jul 31, 2023
f715657
Renames GetBlockByNumberWithTxs to GetBlockBodyByNumber
tjayrush Jul 31, 2023
322e5c1
Renames GetTracesByBlockNumber to GetTracesByNumber to be more consis…
tjayrush Jul 31, 2023
b180139
Renames GetTracesByTransactionId to GetTracesByTransactionID to remov…
tjayrush Jul 31, 2023
707c56f
Removes Id_2_TxHash and Id_2_BlockHash from rpcClient into local inte…
tjayrush Jul 31, 2023
0cd19fe
Removes FetchTransactionById as basically unused
tjayrush Jul 31, 2023
5332fbd
Merge branch 'develop' into feature/improve-rpcClient-package
tjayrush Jul 31, 2023
a0d420c
Moves GetBlockTimestamp from rpc package to rpcClient package
tjayrush Jul 31, 2023
edb0cf4
Renames GetUncleCountByNumber to GetCountUnclesInBlock to be more con…
tjayrush Jul 31, 2023
1467080
Renames GetTraceCountByBlockNumber to GetCountTracesInBlock to be mo…
tjayrush Jul 31, 2023
9d1f9e9
Renames GetLogCountByBlockNumber to GetCountLogsInBlock to be more c…
tjayrush Jul 31, 2023
dae6033
Cleans up use of provider in some places in preparation for larger ch…
tjayrush Jul 31, 2023
3580b5e
Renames GetLogsByBlockNumber to GetLogsByNumber to be more consistent
tjayrush Jul 31, 2023
23e82fb
Renames GetTracesCountByTransactionHash to GetCountTracesInTransactio…
tjayrush Jul 31, 2023
016dbeb
Cleans up use of provider in some places in preparation for larger ch…
tjayrush Jul 31, 2023
5a7320a
Makes NumPair a proper generic pair
tjayrush Jul 31, 2023
8604c03
Renames GetProxy to GetProxyAt to be more consistent
tjayrush Jul 31, 2023
e0e676b
Renames GetTransactionReceipt to GetReceipt to more properly name the…
tjayrush Jul 31, 2023
919c8fb
Various inconsequential cleanups
tjayrush Jul 31, 2023
c00ec22
Adds error return to GetRpcProvider in prep for larger change
tjayrush Jul 31, 2023
8de2ae8
Small cleanup to chifra export
tjayrush Jul 31, 2023
7233fba
Change GetLatestBlockNumber to accept chain instead of provider. Deli…
tjayrush Jul 31, 2023
ce43579
Renames GetTxFromNumberAndId to GetTransactionByNumberAndID and moves…
tjayrush Jul 31, 2023
7cc6274
Renames BlockHashFromNumber to GetBlockHashByNumber and switches prov…
tjayrush Jul 31, 2023
fba0a6a
Removes extraneous IsSmartContract. Uses IsContractAt and error retur…
tjayrush Jul 31, 2023
f1363a0
Renames BlockNumberFromHash to GetBlockNumberByHash and sends chain n…
tjayrush Jul 31, 2023
d475d01
Removes extraneous BlockTransaction type in leiu of string | types.Si…
tjayrush Jul 31, 2023
217d51d
Makes AbiEventFromFunction and AbiMethodFromFunction methods of Simpl…
tjayrush Jul 31, 2023
9acbde3
Adds error return to GetClient (although errors are - for now - ignored)
tjayrush Jul 31, 2023
4cad4e9
Cleaning
tjayrush Jul 31, 2023
a7e19b3
Renames GetTxHashFromNumberAndId to GetTransactionHashByNumberAndID a…
tjayrush Jul 31, 2023
007e573
Fixes build
tjayrush Jul 31, 2023
d78fb43
Some more cleanup. Almost done.
tjayrush Jul 31, 2023
83526ea
Makes all access to the client through GetClient(chain) not GetRpcPro…
tjayrush Jul 31, 2023
31c0a6e
A few final cleanups
tjayrush Jul 31, 2023
c27d7dc
Uses new ContractCall code to call into the Unchained Index
tjayrush Jul 31, 2023
2207155
Hides access to GetClient by making it private to rpcClient
tjayrush Jul 31, 2023
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
380 changes: 380 additions & 0 deletions go.work.sum

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions src/apps/chifra/internal/abis/handle_addresses.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ func (opts *AbisOptions) HandleAddresses() (err error) {
cancel()
}
// Let's try to download the file from somewhere
if err := rpcClient.IsContractAt(opts.Globals.Chain, address, nil); err != nil && !errors.Is(err, rpcClient.ErrNotAContract) {
errorChan <- err
cancel()
} else if errors.Is(err, rpcClient.ErrNotAContract) {
logger.Info("Address", address, "is not a smart contract. Skipping...")
err = nil // not an error to not be a contract
continue
if err := rpcClient.IsContractAt(opts.Globals.Chain, address, nil); err != nil {
if !errors.Is(err, rpcClient.ErrNotAContract) {
errorChan <- err
cancel()
} else {
logger.Info("Address", address, "is not a smart contract. Skipping...")
err = nil // not an error to not be a contract
continue
}
} else {
// It's okay to not find the ABI. We report an error, but do not stop processing
if err = abi.DownloadAbi(opts.Globals.Chain, address, result); err != nil {
Expand Down
13 changes: 6 additions & 7 deletions src/apps/chifra/internal/blocks/handle_count.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/index"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpcClient"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types"
"github.com/ethereum/go-ethereum"
Expand All @@ -26,7 +25,7 @@ func (opts *BlocksOptions) HandleCounts() error {
// If the cache is writeable, fetch the latest block timestamp so that we never
// cache pending blocks
if !rpcOptions.Store.ReadOnly() {
rpcOptions.LatestBlockTimestamp = rpc.GetBlockTimestamp(opts.Globals.Chain, nil)
rpcOptions.LatestBlockTimestamp = rpcClient.GetBlockTimestamp(opts.Globals.Chain, nil)
}

chain := opts.Globals.Chain
Expand All @@ -46,7 +45,7 @@ func (opts *BlocksOptions) HandleCounts() error {

for _, bn := range blockNums {
var block types.SimpleBlock[string]
if block, err = rpcClient.GetBlockByNumber(chain, bn, rpcClient.NoOptions); err != nil {
if block, err = rpcClient.GetBlockHeaderByNumber(chain, bn, rpcClient.NoOptions); err != nil {
errorChan <- err
if errors.Is(err, ethereum.NotFound) {
continue
Expand All @@ -62,7 +61,7 @@ func (opts *BlocksOptions) HandleCounts() error {
}

if opts.Uncles {
if blockCount.UnclesCnt, err = rpcClient.GetUncleCountByNumber(chain, bn); err != nil {
if blockCount.UnclesCnt, err = rpcClient.GetCountUnclesInBlock(chain, bn); err != nil {
errorChan <- err
if errors.Is(err, ethereum.NotFound) {
continue
Expand All @@ -73,7 +72,7 @@ func (opts *BlocksOptions) HandleCounts() error {
}

if opts.Traces {
if blockCount.TracesCnt, err = rpcClient.GetTraceCountByBlockNumber(chain, bn); err != nil {
if blockCount.TracesCnt, err = rpcClient.GetCountTracesInBlock(chain, bn); err != nil {
errorChan <- err
if errors.Is(err, ethereum.NotFound) {
continue
Expand All @@ -84,7 +83,7 @@ func (opts *BlocksOptions) HandleCounts() error {
}

if opts.Logs {
if blockCount.LogsCnt, err = rpcClient.GetLogCountByBlockNumber(chain, bn); err != nil {
if blockCount.LogsCnt, err = rpcClient.GetCountLogsInBlock(chain, bn); err != nil {
errorChan <- err
if errors.Is(err, ethereum.NotFound) {
continue
Expand All @@ -101,7 +100,7 @@ func (opts *BlocksOptions) HandleCounts() error {
}

addrMap := make(index.AddressBooleanMap)
ts := rpc.GetBlockTimestamp(chain, &bn)
ts := rpcClient.GetBlockTimestamp(chain, &bn)
if err := opts.ProcessBlockUniqs(chain, countFunc, bn, addrMap, ts, rpcOptions); err != nil {
errorChan <- err
if errors.Is(err, ethereum.NotFound) {
Expand Down
8 changes: 4 additions & 4 deletions src/apps/chifra/internal/blocks/handle_decache.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (opts *BlocksOptions) HandleDecache() error {
return err
}
for _, bn := range blockNums {
rawBlock, err := rpcClient.GetBlockByNumberWithTxs(opts.Globals.Chain, bn, rpcOptions)
rawBlock, err := rpcClient.GetBlockBodyByNumber(opts.Globals.Chain, bn, rpcOptions)
if err != nil {
return err
}
Expand Down Expand Up @@ -75,19 +75,19 @@ func (opts *BlocksOptions) HandleDecache() error {
return nil

// TODO: Review then remove
// pairs := []base.NumPair[uint32]{}
// pairs := []base.Pair[uint32,uint32]{}
// for _, br := range opts.BlockIds {
// blockNums, err := br.ResolveBlocks(opts.Globals.Chain)
// if err != nil {
// return err
// }
// for _, bn := range blockNums {
// rawBlock, err := rpcClient.GetBlockByNumberWithTxs(opts.Globals.Chain, bn, nil)
// rawBlock, err := rpcClient.GetBlockBodyByNumber(opts.Globals.Chain, bn, nil)
// if err != nil {
// return err
// }
// for _, tx := range rawBlock.Transactions {
// pairs = append(pairs, base.NumPair[uint32]{N1: uint32(bn), N2: uint32(tx.TransactionIndex)})
// pairs = append(pairs, base.Pair[uint32,uint32]{N1: uint32(bn), N2: uint32(tx.TransactionIndex)})
// }
// }
// }
Expand Down
2 changes: 1 addition & 1 deletion src/apps/chifra/internal/blocks/handle_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (opts *BlocksOptions) HandleList() error {
ctx, cancel := context.WithCancel(context.Background())
fetchData := func(modelChan chan types.Modeler[types.RawBlock], errorChan chan error) {
for bn := start; bn > end; bn-- {
block, err := rpcClient.GetBlockByNumber(opts.Globals.Chain, bn, rpcOptions)
block, err := rpcClient.GetBlockHeaderByNumber(opts.Globals.Chain, bn, rpcOptions)
if err != nil {
errorChan <- err
if errors.Is(err, ethereum.NotFound) {
Expand Down
7 changes: 3 additions & 4 deletions src/apps/chifra/internal/blocks/handle_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"errors"

"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpcClient"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types"
"github.com/ethereum/go-ethereum"
Expand All @@ -25,7 +24,7 @@ func (opts *BlocksOptions) HandleShowBlocks() error {
// If the cache is writeable, fetch the latest block timestamp so that we never
// cache pending blocks
if !rpcOptions.Store.ReadOnly() {
rpcOptions.LatestBlockTimestamp = rpc.GetBlockTimestamp(opts.Globals.Chain, nil)
rpcOptions.LatestBlockTimestamp = rpcClient.GetBlockTimestamp(opts.Globals.Chain, nil)
}

ctx, cancel := context.WithCancel(context.Background())
Expand All @@ -47,11 +46,11 @@ func (opts *BlocksOptions) HandleShowBlocks() error {
var err error
if !opts.Hashes {
var b types.SimpleBlock[types.SimpleTransaction]
b, err = rpcClient.GetBlockByNumberWithTxs(opts.Globals.Chain, bn, rpcOptions)
b, err = rpcClient.GetBlockBodyByNumber(opts.Globals.Chain, bn, rpcOptions)
block = &b
} else {
var b types.SimpleBlock[string]
b, err = rpcClient.GetBlockByNumber(opts.Globals.Chain, bn, rpcOptions)
b, err = rpcClient.GetBlockHeaderByNumber(opts.Globals.Chain, bn, rpcOptions)
block = &b
}

Expand Down
2 changes: 1 addition & 1 deletion src/apps/chifra/internal/blocks/handle_traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (opts *BlocksOptions) HandleTraces() error {

for _, bn := range blockNums {
var traces []types.SimpleTrace
traces, err = rpcClient.GetTracesByBlockNumber(chain, bn)
traces, err = rpcClient.GetTracesByNumber(chain, bn)
if err != nil {
errorChan <- err
if errors.Is(err, ethereum.NotFound) {
Expand Down
4 changes: 2 additions & 2 deletions src/apps/chifra/internal/blocks/handle_uncles.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ func (opts *BlocksOptions) HandleUncles() error {
var err error
if !opts.Hashes {
var b types.SimpleBlock[types.SimpleTransaction]
b, err = rpcClient.GetBlockByNumberWithTxs(opts.Globals.Chain, bn, rpcOptions)
b, err = rpcClient.GetBlockBodyByNumber(opts.Globals.Chain, bn, rpcOptions)
block = &b
} else {
var b types.SimpleBlock[string]
b, err = rpcClient.GetBlockByNumber(opts.Globals.Chain, bn, rpcOptions)
b, err = rpcClient.GetBlockHeaderByNumber(opts.Globals.Chain, bn, rpcOptions)
block = &b
}

Expand Down
9 changes: 4 additions & 5 deletions src/apps/chifra/internal/blocks/handle_uniq.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/names"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpcClient"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/utils"
Expand All @@ -26,7 +25,7 @@ func (opts *BlocksOptions) HandleUniq() (err error) {
// If the cache is writeable, fetch the latest block timestamp so that we never
// cache pending blocks
if !rpcOptions.Store.ReadOnly() {
rpcOptions.LatestBlockTimestamp = rpc.GetBlockTimestamp(opts.Globals.Chain, nil)
rpcOptions.LatestBlockTimestamp = rpcClient.GetBlockTimestamp(opts.Globals.Chain, nil)
}

ctx, cancel := context.WithCancel(context.Background())
Expand All @@ -52,7 +51,7 @@ func (opts *BlocksOptions) HandleUniq() (err error) {
logger.Info("Processing block", fmt.Sprintf("%d", bn))
}
addrMap := make(index.AddressBooleanMap)
ts := rpc.GetBlockTimestamp(chain, &bn)
ts := rpcClient.GetBlockTimestamp(chain, &bn)
if err := opts.ProcessBlockUniqs(chain, procFunc, bn, addrMap, ts, rpcOptions); err != nil {
errorChan <- err
if errors.Is(err, ethereum.NotFound) {
Expand Down Expand Up @@ -83,7 +82,7 @@ func (opts *BlocksOptions) ProcessBlockUniqs(chain string, procFunc index.UniqPr
}

} else {
if block, err := rpcClient.GetBlockByNumberWithTxs(chain, bn, rpcOptions); err != nil {
if block, err := rpcClient.GetBlockBodyByNumber(chain, bn, rpcOptions); err != nil {
return err
} else {
miner := block.Miner.Hex()
Expand Down Expand Up @@ -113,7 +112,7 @@ func (opts *BlocksOptions) ProcessBlockUniqs(chain string, procFunc index.UniqPr
}

for _, trans := range block.Transactions {
if trans.Traces, err = rpcClient.GetTracesByTransactionId(opts.Globals.Chain, trans.BlockNumber, trans.TransactionIndex, rpcOptions); err != nil {
if trans.Traces, err = rpcClient.GetTracesByTransactionID(opts.Globals.Chain, trans.BlockNumber, trans.TransactionIndex, rpcOptions); err != nil {
return err
}
if err = index.UniqFromTransDetails(chain, procFunc, opts.Flow, &trans, ts, addrMap, rpcOptions); err != nil {
Expand Down
4 changes: 3 additions & 1 deletion src/apps/chifra/internal/daemon/handle_calls.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,16 @@ func CallOne(w http.ResponseWriter, r *http.Request, tbCmd, extra, apiCmd string
}()
}

provider, _ := config.GetRpcProvider(chain)

var env config.ConfigEnv
env.Chain = chain
env.ConfigPath = config.GetPathToRootConfig()
env.CachePath = config.GetPathToCache(env.Chain)
env.ChainConfigPath = config.GetPathToChainConfig(env.Chain) // order matters
env.IndexPath = config.GetPathToIndex(env.Chain) // order matters
env.DefaultChain = config.GetDefaultChain()
env.RpcProvider = config.GetRpcProvider(env.Chain)
env.RpcProvider = provider
envStr := env.ToCSV()

if utils.IsTestModeServer(r) {
Expand Down
4 changes: 3 additions & 1 deletion src/apps/chifra/internal/daemon/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ func (opts *DaemonOptions) DaemonInternal() (err error, handled bool) {
}

chain := opts.Globals.Chain
provider, _ := config.GetRpcProvider(chain)

logger.InfoTable("Server URL: ", apiUrl)
logger.InfoTable("RPC Provider: ", config.GetRpcProvider(chain))
logger.InfoTable("RPC Provider: ", provider)
logger.InfoTable("Root Config Path: ", config.GetPathToRootConfig())
logger.InfoTable("Chain Config Path: ", config.GetPathToChainConfig(chain))
logger.InfoTable("Cache Path: ", config.GetPathToCache(chain))
Expand Down
52 changes: 50 additions & 2 deletions src/apps/chifra/internal/explore/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package explorePkg

import (
"fmt"
"strconv"
"strings"

"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base"
Expand Down Expand Up @@ -68,7 +69,7 @@ func (opts *ExploreOptions) validateExplore() error {

valid, _ := validate.IsValidTransId(opts.Globals.Chain, []string{arg}, validate.ValidTransId)
if valid {
txHash, err := rpcClient.Id_2_TxHash(opts.Globals.Chain, arg, validate.IsBlockHash)
txHash, err := idToTxHash(opts.Globals.Chain, arg, validate.IsBlockHash)
if err == nil {
urls = append(urls, ExploreUrl{txHash, ExploreTx})
continue
Expand All @@ -78,7 +79,7 @@ func (opts *ExploreOptions) validateExplore() error {

valid, _ = validate.IsValidBlockId(opts.Globals.Chain, []string{arg}, validate.ValidBlockIdWithRangeAndDate)
if valid {
blockHash, err := rpcClient.Id_2_BlockHash(opts.Globals.Chain, arg, validate.IsBlockHash)
blockHash, err := idToBlockHash(opts.Globals.Chain, arg, validate.IsBlockHash)
if err == nil {
urls = append(urls, ExploreUrl{blockHash, ExploreBlock})
continue
Expand Down Expand Up @@ -123,3 +124,50 @@ func (t ExploreType) String() string {
return fmt.Sprintf("%d", t)
}
}

func idToBlockHash(chain, arg string, isBlockHash func(arg string) bool) (string, error) {
if isBlockHash(arg) {
return rpcClient.GetBlockHashFromHashStr(chain, arg)
}

blockNum, err := strconv.ParseUint(arg, 10, 64)
if err != nil {
return "", nil
}
return rpcClient.GetBlockHashByNumber(chain, blockNum)
}

// idToTxHash takes a valid identifier (txHash/blockHash, blockHash.txId, blockNumber.txId)
// and returns the transaction hash represented by that identifier. (If it's a valid transaction.
// It may not be because transaction hashes and block hashes are both 32-byte hex)
func idToTxHash(chain, arg string, isBlockHash func(arg string) bool) (string, error) {
// simple case first
if !strings.Contains(arg, ".") {
// We know it's a hash, but we want to know if it's a legitimate tx on chain
return rpcClient.GetTransactionHashFromHashStr(chain, arg)
}

parts := strings.Split(arg, ".")
if len(parts) != 2 {
panic("Programmer error - valid transaction identifiers with a `.` must have two and only two parts")
}

if isBlockHash(parts[0]) {
txId, err := strconv.ParseUint(parts[1], 10, 64)
if err != nil {
return "", nil
}
return rpcClient.GetTransactionHashByHashAndID(chain, parts[0], txId)
}

blockNum, err := strconv.ParseUint(parts[0], 10, 64)
if err != nil {
return "", nil
}
txId, err := strconv.ParseUint(parts[1], 10, 64)
if err != nil {
return "", nil
}

return rpcClient.GetTransactionHashByNumberAndID(chain, blockNum, txId)
}
4 changes: 3 additions & 1 deletion src/apps/chifra/internal/export/handle_receipts.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ func (opts *ExportOptions) HandleReceipts(monitorArray []monitor.Monitor) error
base.BlockRange{First: opts.FirstBlock, Last: opts.LastBlock},
base.RecordRange{First: opts.FirstRecord, Last: opts.GetMax()},
)
rpcOptions := rpcClient.DefaultRpcOptions(nil)
rpcOptions := rpcClient.DefaultRpcOptions(&rpcClient.DefaultRpcOptionsSettings{
Chain: chain,
})

ctx := context.Background()
fetchData := func(modelChan chan types.Modeler[types.RawReceipt], errorChan chan error) {
Expand Down
5 changes: 4 additions & 1 deletion src/apps/chifra/internal/export/handle_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ func (opts *ExportOptions) HandleShow(monitorArray []monitor.Monitor) error {
base.BlockRange{First: opts.FirstBlock, Last: opts.LastBlock},
base.RecordRange{First: opts.FirstRecord, Last: opts.GetMax()},
)
rpcOptions := rpcClient.DefaultRpcOptions(nil)
rpcOptions := rpcClient.DefaultRpcOptions(&rpcClient.DefaultRpcOptionsSettings{
Chain: chain,
Opts: opts,
})

ctx := context.Background()
fetchData := func(modelChan chan types.Modeler[types.RawTransaction], errorChan chan error) {
Expand Down
4 changes: 3 additions & 1 deletion src/apps/chifra/internal/export/handle_statements.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ func (opts *ExportOptions) HandleStatements(monitorArray []monitor.Monitor) erro
base.BlockRange{First: opts.FirstBlock, Last: opts.LastBlock},
base.RecordRange{First: opts.FirstRecord, Last: opts.GetMax()},
)
rpcOptions := rpcClient.DefaultRpcOptions(nil)
rpcOptions := rpcClient.DefaultRpcOptions(&rpcClient.DefaultRpcOptionsSettings{
Chain: chain,
})

ctx := context.Background()
fetchData := func(modelChan chan types.Modeler[types.RawStatement], errorChan chan error) {
Expand Down
4 changes: 3 additions & 1 deletion src/apps/chifra/internal/export/handle_traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ func (opts *ExportOptions) HandleTraces(monitorArray []monitor.Monitor) error {
base.BlockRange{First: opts.FirstBlock, Last: opts.LastBlock},
base.RecordRange{First: opts.FirstRecord, Last: opts.GetMax()},
)
rpcOptions := rpcClient.DefaultRpcOptions(nil)
rpcOptions := rpcClient.DefaultRpcOptions(&rpcClient.DefaultRpcOptionsSettings{
Chain: chain,
})

ctx := context.Background()
fetchData := func(modelChan chan types.Modeler[types.RawTrace], errorChan chan error) {
Expand Down
9 changes: 9 additions & 0 deletions src/apps/chifra/internal/export/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,4 +322,13 @@ func ResetOptions() {
}

// EXISTING_CODE
//

// CacheState returns booleans indicating if transaction cache and trace
// cache should be writable (usually it is set by the user using --cache_txs
// and --cache_traces flags)
func (opts *ExportOptions) CacheState() (bool, bool, bool) {
return opts.Globals.Cache, true, opts.CacheTraces
}

// EXISTING_CODE
Loading