Skip to content
New issue

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

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

Already on GitHub? # to your account

Complete the document of the algorithm for finding payment path #57

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

Complete the document of the algorithm for finding payment path #57

neocarmack opened this issue Mar 4, 2022 · 2 comments · May be fixed by #54
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@neocarmack
Copy link
Member

neocarmack commented Mar 4, 2022

this issue is the 11 bug in issue 53: #53

  1. (to to) func (manager *htlcManager) getPath(msgData string) (path interface{}, err error) shoud have a document: the main flow,and how to use the returned value.

func (manager *htlcManager) getPath(obdClient *ObdNode, msgData string) (path interface{}, err error) {
manager.mu.Lock()
defer manager.mu.Unlock()
log.Println("getPath", msgData)
if tool.CheckIsString(&msgData) == false {
return "", errors.New("wrong inputData")
}
pathRequest := &bean.HtlcPathRequest{}
err = json.Unmarshal([]byte(msgData), pathRequest)
if err != nil {
return "", err
}
if tool.CheckIsString(&pathRequest.RealPayerPeerId) == false {
return "", errors.New("wrong realPayerPeerId")
}
if tool.CheckIsString(&pathRequest.PayeePeerId) == false {
return "", errors.New("wrong SendeePeerId")
}
if pathRequest.Amount < tool.GetOmniDustBtc() {
return "", errors.New("wrong amount")
}
manager.createChannelNetwork(pathRequest.RealPayerPeerId, pathRequest.PayeePeerId, pathRequest.PropertyId, pathRequest.Amount, nil, true)
resultIndex := manager.getPathIndex()
retNode := make(map[string]interface{})
retNode["senderPeerId"] = pathRequest.RealPayerPeerId
retNode["h"] = pathRequest.H
retNode["amount"] = pathRequest.Amount
retNode["path"] = ""
if resultIndex != -1 {
splitArr := strings.Split(manager.openList[resultIndex].ChannelIds, ",")
path := ""
for i := len(splitArr) - 1; i > -1; i-- {
path += splitArr[i] + ","
}
path = strings.TrimSuffix(path, ",")
retNode["path"] = path
}
log.Println("return path info", retNode)
return retNode, nil
}

@neocarmack neocarmack added the documentation Improvements or additions to documentation label Mar 4, 2022
@neocarmack neocarmack linked a pull request Mar 4, 2022 that will close this issue
@neocarmack
Copy link
Member Author

path-finding-strategies

currently implemented path finding algorithm is the greedy best-first search algorithm.

@neocarmack
Copy link
Member Author

Dijkstra algorithm and A star algorithm should be implemented.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants