Skip to content

Commit

Permalink
fix update lending pair
Browse files Browse the repository at this point in the history
  • Loading branch information
thanhson1085 committed May 17, 2020
1 parent 9f52bca commit 1b3b02c
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions services/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (s *RelayerService) updatePairRelayer(relayerInfo *relayer.RInfo) error {

func (s *RelayerService) updateLendingPair(relayerInfo *relayer.LendingRInfo) error {
currentPairs, err := s.lendingPairDao.GetAllByCoinbase(relayerInfo.Address)
logger.Info("UpdateLendingPairRelayer starting...")
logger.Info("UpdateLendingPairRelayer starting...", relayerInfo.Address.Hex(), len(relayerInfo.LendingPairs), len(currentPairs))
if err != nil {
return err
}
Expand Down Expand Up @@ -166,8 +166,8 @@ func (s *RelayerService) updateLendingPair(relayerInfo *relayer.LendingRInfo) er
}
if !found {
logger.Info("Delete Pair:", currentPair.Term, currentPair.LendingTokenAddress.Hex())
err := s.lendingPairDao.DeleteByLendingKey(currentPair.Term, currentPair.LendingTokenAddress)
if err == nil {
err := s.lendingPairDao.DeleteByLendingKeyAndCoinbase(currentPair.Term, currentPair.LendingTokenAddress, relayerInfo.Address)
if err != nil {
logger.Error(err)
}
}
Expand Down Expand Up @@ -457,15 +457,17 @@ func (s *RelayerService) UpdateRelayer(coinbase common.Address) error {
}

func (s *RelayerService) UpdateRelayers() error {
relayerInfos, err := s.relayer.GetRelayers()
if err != nil {
return err
}
for _, relayerInfo := range relayerInfos {
s.updateTokenRelayer(relayerInfo)
s.updatePairRelayer(relayerInfo)
}
/*
relayerInfos, err := s.relayer.GetRelayers()
if err != nil {
return err
}
for _, relayerInfo := range relayerInfos {
s.updateTokenRelayer(relayerInfo)
s.updatePairRelayer(relayerInfo)
}
*/
relayerLendingInfos, err := s.relayer.GetLendings()
if err != nil {
return err
Expand All @@ -475,6 +477,6 @@ func (s *RelayerService) UpdateRelayers() error {
s.updateCollateralTokenRelayer(relayerLendingInfo)
s.updateLendingTokenRelayer(relayerLendingInfo)
}
s.updateRelayers(relayerInfos, relayerLendingInfos)
// s.updateRelayers(relayerInfos, relayerLendingInfos)
return nil
}

0 comments on commit 1b3b02c

Please sign in to comment.