Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
neocarmack opened this issue Mar 4, 2022 · 0 comments · May be fixed by #54
Open

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

neocarmack opened this issue Mar 4, 2022 · 0 comments · May be fixed by #54
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@neocarmack
Copy link
Member

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.
@neocarmack neocarmack added bug Something isn't working enhancement New feature or request labels Mar 4, 2022
@neocarmack neocarmack linked a pull request Mar 4, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants