This commit is contained in:
parent
9e6abb1112
commit
4d5dcc46d2
@ -46,26 +46,25 @@ type Asset struct {
|
||||
RelativeBases []moon.RelativeBase `koanf:"relativeBases"`
|
||||
}
|
||||
|
||||
func (r Root) ForAsset(asset coindesk.Asset) (data Asset) {
|
||||
data, ok := r.Assets[asset]
|
||||
if !ok {
|
||||
data = r.Defaults
|
||||
}
|
||||
if data.Asset == "" {
|
||||
data.Asset = asset
|
||||
}
|
||||
if data.Goals == nil || len(data.Goals) == 0 {
|
||||
data.Goals = r.Defaults.Goals
|
||||
}
|
||||
if data.ConstantBases == nil || len(data.ConstantBases) == 0 {
|
||||
data.ConstantBases = r.Defaults.ConstantBases
|
||||
}
|
||||
if data.RelativeBases == nil || len(data.RelativeBases) == 0 {
|
||||
data.RelativeBases = r.Defaults.RelativeBases
|
||||
}
|
||||
func (r Root) ForAsset(a coindesk.Asset) (cfg Asset) {
|
||||
cfg = merge(r.Assets[a], r.Defaults)
|
||||
cfg.Asset = a
|
||||
return
|
||||
}
|
||||
|
||||
func merge(dst, src Asset) Asset {
|
||||
if len(dst.Goals) == 0 {
|
||||
dst.Goals = src.Goals
|
||||
}
|
||||
if len(dst.ConstantBases) == 0 {
|
||||
dst.ConstantBases = src.ConstantBases
|
||||
}
|
||||
if len(dst.RelativeBases) == 0 {
|
||||
dst.RelativeBases = src.RelativeBases
|
||||
}
|
||||
return dst
|
||||
}
|
||||
|
||||
// GetBases returns the concatenation of the constant and relative bases, sorted
|
||||
// from most recent to least recent in time.
|
||||
func GetBases(d *Asset) (bases []moon.Base) {
|
||||
|
@ -148,9 +148,9 @@ type update struct {
|
||||
type stopIndicator struct{}
|
||||
|
||||
func (m Model) refresh() tea.Msg {
|
||||
ctx, cancel := context.WithDeadline(
|
||||
ctx, cancel := context.WithTimeout(
|
||||
context.Background(),
|
||||
time.Now().Add(refreshDeadline))
|
||||
refreshTimeout)
|
||||
defer cancel()
|
||||
err := m.math.Refresh(ctx)
|
||||
if err != nil {
|
||||
@ -183,7 +183,7 @@ func (m Model) stopIndicator() tea.Cmd {
|
||||
}
|
||||
|
||||
var refreshInterval = time.Second * 30
|
||||
var refreshDeadline = time.Second * 15
|
||||
var refreshTimeout = time.Second * 15
|
||||
var stopIndicatorDelay = time.Millisecond * 500
|
||||
|
||||
func refillProperties(m *Model) {
|
||||
|
Loading…
Reference in New Issue
Block a user