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