1
This commit is contained in:
parent
9982b8bc9a
commit
9775c0da00
@ -95,23 +95,34 @@ func (this *vip) RecalcEsCecConvert(accountAddress string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var lastWithdraw *vesterDepositWithdrawPo
|
||||
allDeposits := []*vesterDepositWithdrawPo{}
|
||||
for ds.Next() {
|
||||
p := new(vesterDepositWithdrawPo)
|
||||
p.eventName = ds.GetByName("event_name")
|
||||
p.chainTimestamp = q5.ToInt32(ds.GetByName("chain_timestamp"))
|
||||
p.accountAddress = ds.GetByName("account_address")
|
||||
p.depositAmount = ds.GetByName("deposit_amount")
|
||||
p.withdrawClamiedAmount = ds.GetByName("withdraw_clamied_amount")
|
||||
p.withdrawBalance = ds.GetByName("withdraw_balance")
|
||||
if p.eventName == constant.VESTER_DEPOSIT_EVENT_NAME {
|
||||
q5.AppendSlice(&allDeposits, p)
|
||||
} else if p.eventName == constant.VESTER_WITHDRAW_EVENT_NAME {
|
||||
if lastWithdraw == nil || lastWithdraw.chainTimestamp < p.chainTimestamp {
|
||||
lastWithdraw = p
|
||||
matchDeposits := []*vesterDepositWithdrawPo{}
|
||||
{
|
||||
var lastWithdraw *vesterDepositWithdrawPo
|
||||
allDeposits := []*vesterDepositWithdrawPo{}
|
||||
for ds.Next() {
|
||||
p := new(vesterDepositWithdrawPo)
|
||||
p.eventName = ds.GetByName("event_name")
|
||||
p.chainTimestamp = q5.ToInt32(ds.GetByName("chain_timestamp"))
|
||||
p.accountAddress = ds.GetByName("account_address")
|
||||
p.depositAmount = ds.GetByName("deposit_amount")
|
||||
p.withdrawClamiedAmount = ds.GetByName("withdraw_clamied_amount")
|
||||
p.withdrawBalance = ds.GetByName("withdraw_balance")
|
||||
if p.eventName == constant.VESTER_DEPOSIT_EVENT_NAME {
|
||||
q5.AppendSlice(&allDeposits, p)
|
||||
} else if p.eventName == constant.VESTER_WITHDRAW_EVENT_NAME {
|
||||
if lastWithdraw == nil || lastWithdraw.chainTimestamp < p.chainTimestamp {
|
||||
lastWithdraw = p
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, val := range allDeposits {
|
||||
if lastWithdraw == nil || val.chainTimestamp > lastWithdraw.chainTimestamp {
|
||||
q5.AppendSlice(&matchDeposits, val)
|
||||
}
|
||||
}
|
||||
}
|
||||
q5.Sort(matchDeposits, func (a *vesterDepositWithdrawPo, b *vesterDepositWithdrawPo) bool {
|
||||
return a.chainTimestamp < b.chainTimestamp
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user