Skip to content

The data sync mechanism between obd and tracker need update.  #58

@neocarmack

Description

@neocarmack

This issue is the bug 12 and 13 in issue 53

  1. (fixed) obd/service/user.go line 60 calls noticeTrackerUserLogin().sendMsgToTracker() .

    obd/service/user.go

    Lines 20 to 76 in 5829315

    func (service *UserManager) UserLogin(user *bean.User) error {
    if user == nil {
    return errors.New(enum.Tips_user_nilUser)
    }
    if user.IsAdmin {
    if tool.CheckIsString(&user.Mnemonic) == false || bip39.IsMnemonicValid(user.Mnemonic) == false {
    return errors.New(enum.Tips_common_wrong + "mnemonic")
    }
    changeExtKey, err := HDWalletService.CreateChangeExtKey(user.Mnemonic)
    if err != nil {
    return err
    }
    user.PeerId = tool.GetUserPeerId(user.Mnemonic)
    user.ChangeExtKey = changeExtKey
    }
    userDB, err := dao.DBService.GetUserDB(user.PeerId)
    if err != nil {
    return err
    }
    var node dao.User
    err = userDB.Select(q.Eq("PeerId", user.PeerId)).First(&node)
    if node.Id == 0 {
    node = dao.User{}
    node.PeerId = user.PeerId
    node.P2PLocalPeerId = user.P2PLocalPeerId
    node.P2PLocalAddress = user.P2PLocalAddress
    node.CurrState = bean.UserState_OnLine
    node.CreateAt = time.Now()
    node.LatestLoginTime = node.CreateAt
    node.CurrAddrIndex = 0
    err = userDB.Save(&node)
    } else {
    node.P2PLocalPeerId = user.P2PLocalPeerId
    node.P2PLocalAddress = user.P2PLocalAddress
    node.CurrState = bean.UserState_OnLine
    node.LatestLoginTime = time.Now()
    err = userDB.Update(&node)
    }
    noticeTrackerUserLogin(node)
    if err != nil {
    return err
    }
    loginLog := &dao.UserLoginLog{}
    loginLog.PeerId = user.PeerId
    loginLog.LoginAt = time.Now()
    _ = userDB.Save(loginLog)
    user.State = node.CurrState
    user.CurrAddrIndex = node.CurrAddrIndex
    user.Db = userDB
    return nil
    }
  • issue 1: if some err occurs ,we MUST not invoke it (L60). If it noticeTrackerUserLogin just record a audit-log, we can ignore the err and invoke it.
  • issue 2: obd/service is just a database/data operation module, it MUST not call sendMsgToTracker to send async message; obd/lightclient module is async message center, now 95% async messages are recieved and sent here, all the client-websocket-conn p2p-conn are initialized here; obd/service/htlc_tx_forward.go PayerRequestFindPath invoke "sendMsgToTracker(enum.MsgType_Tracker_GetHtlcPath_351, pathRequest)" have the same probolem.
  • now i have fixed the two issue, and obd/service.sendMsgToTracker have disbled, and below messages submit by grpc-conn now,no need to sync userInfo/channelInfo/htlcInfo to tracker with complex async message Goroutines. the old msgList:
    • MsgType_Tracker_UpdateChannelInfo_350
    • MsgType_Tracker_UserLogin_304
    • MsgType_Tracker_UserLogout_305
    • MsgType_Tracker_UpdateHtlcTxState_352
  1. (to to) may be we should design the obd-tracker info sync-mode and security first. Maybe new mechanism won't need the above work.

Metadata

Metadata

Labels

bugSomething isn't workingenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions