github.com/TrueBlocks/trueblocks-core/src/apps/chifra@v0.0.0-20241022031540-b362680128f7/pkg/decache/locations_from_transactions.go (about) 1 package decache 2 3 import ( 4 "errors" 5 6 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" 7 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/cache" 8 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/identifiers" 9 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc" 10 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 11 "github.com/ethereum/go-ethereum" 12 ) 13 14 func LocationsFromTransactions(conn *rpc.Connection, ids []identifiers.Identifier) ([]cache.Locator, error) { 15 locations := make([]cache.Locator, 0) 16 for _, rng := range ids { 17 txIds, err := rng.ResolveTxs(conn.Chain) 18 if err != nil && !errors.Is(err, ethereum.NotFound) { 19 continue 20 } 21 for _, app := range txIds { 22 // walk.Cache_Transactions 23 tx := &types.Transaction{ 24 BlockNumber: base.Blknum(app.BlockNumber), 25 TransactionIndex: base.Txnum(app.TransactionIndex), 26 } 27 locations = append(locations, tx) 28 29 // walk.Cache_Traces 30 locations = append(locations, &types.TraceGroup{ 31 BlockNumber: tx.BlockNumber, 32 TransactionIndex: tx.TransactionIndex, 33 }) 34 } 35 } 36 return locations, nil 37 }