make default sync simple

This commit is contained in:
c9s 2022-06-18 01:42:24 +08:00
parent 01202e353b
commit ac404b20a5
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -617,7 +617,7 @@ func (environ *Environment) syncWithUserConfig(ctx context.Context, userConfig *
}
if userConfig.Sync.RewardHistory {
if err := environ.SyncService.SyncRewardHistory(ctx, session.Exchange); err != nil {
if err := environ.SyncService.SyncRewardHistory(ctx, session.Exchange, since); err != nil {
return err
}
}
@ -656,35 +656,11 @@ func (environ *Environment) Sync(ctx context.Context, userConfig ...*Config) err
return environ.syncWithUserConfig(ctx, userConfig[0])
}
since := time.Now().AddDate(0, -6, 0)
// the default sync logics
for _, session := range environ.sessions {
if err := environ.syncSession(ctx, session); err != nil {
return err
}
if len(userConfig) == 0 || userConfig[0].Sync == nil {
continue
}
if userConfig[0].Sync.DepositHistory {
if err := environ.SyncService.SyncDepositHistory(ctx, session.Exchange, since); err != nil {
return err
}
}
if userConfig[0].Sync.WithdrawHistory {
if err := environ.SyncService.SyncWithdrawHistory(ctx, session.Exchange, since); err != nil {
return err
}
}
if userConfig[0].Sync.RewardHistory {
if err := environ.SyncService.SyncRewardHistory(ctx, session.Exchange); err != nil {
return err
}
}
}
return nil