fix bug in getTmpLinkCost, seems works ok