forked from stellar/go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
path.go
executable file
·43 lines (37 loc) · 989 Bytes
/
path.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
37
38
39
40
41
42
43
package resourceadapter
import (
"context"
"github.com/fonero-project/fonero-golang/amount"
"github.com/fonero-project/fonero-golang/protocols/horizon"
"github.com/fonero-project/fonero-golang/services/horizon/internal/paths"
)
// PopulatePath converts the paths.Path into a Path
func PopulatePath(ctx context.Context, dest *horizon.Path, q paths.Query, p paths.Path) (err error) {
dest.DestinationAmount = amount.String(q.DestinationAmount)
dest.SourceAmount = amount.String(p.Cost)
err = p.Source.Extract(
&dest.SourceAssetType,
&dest.SourceAssetCode,
&dest.SourceAssetIssuer)
if err != nil {
return
}
err = p.Destination.Extract(
&dest.DestinationAssetType,
&dest.DestinationAssetCode,
&dest.DestinationAssetIssuer)
if err != nil {
return
}
dest.Path = make([]horizon.Asset, len(p.Path))
for i, a := range p.Path {
err = a.Extract(
&dest.Path[i].Type,
&dest.Path[i].Code,
&dest.Path[i].Issuer)
if err != nil {
return
}
}
return
}