github.com/TrueBlocks/trueblocks-core/src/apps/chifra@v0.0.0-20241022031540-b362680128f7/pkg/identifiers/app_map.go (about) 1 package identifiers 2 3 import ( 4 "strings" 5 6 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 7 ) 8 9 func IdsToApps(chain string, ids []Identifier) ([]types.Appearance, int, error) { 10 ret := make([]types.Appearance, 0, 100 /* good guess */) 11 for index, rng := range ids { 12 if apps, err := rng.ResolveTxs(chain); err != nil { 13 if blockIds, err := rng.ResolveBlocks(chain); err != nil { 14 return nil, 0, err 15 } else { 16 for _, bn := range blockIds { 17 s := types.Appearance{ 18 BlockNumber: uint32(bn), 19 Reason: strings.Replace(ids[index].Orig, "-", ".", -1), 20 } 21 ret = append(ret, s) 22 } 23 } 24 } else { 25 for _, app := range apps { 26 s := types.Appearance{ 27 BlockNumber: uint32(app.BlockNumber), 28 TransactionIndex: uint32(app.TransactionIndex), 29 Reason: strings.Replace(ids[index].Orig, "-", ".", -1), 30 } 31 ret = append(ret, s) 32 } 33 } 34 } 35 return ret, len(ret), nil 36 }