Skip to content

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

@neocarmack

Description

@neocarmack

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
}

Metadata

Metadata

Labels

documentationImprovements or additions to documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions