github.com/TrueBlocks/trueblocks-core/src/apps/chifra@v0.0.0-20241022031540-b362680128f7/pkg/decache/locations_from_state.go (about) 1 package decache 2 3 import ( 4 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" 5 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/cache" 6 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/identifiers" 7 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc" 8 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 9 ) 10 11 func LocationsFromState(conn *rpc.Connection, address base.Address, ids []identifiers.Identifier) ([]cache.Locator, error) { 12 locations := make([]cache.Locator, 0) 13 for _, br := range ids { 14 blockNums, err := br.ResolveBlocks(conn.Chain) 15 if err != nil { 16 return nil, err 17 } 18 for _, bn := range blockNums { 19 // walk.Cache_State 20 locations = append(locations, &types.State{ 21 BlockNumber: bn, 22 Address: address, 23 }) 24 } 25 } 26 return locations, nil 27 }