public async void UpdateChannelPolicy(double feerate, bool global = true, ChannelPoint channelPoint = null) { var request = new PolicyUpdateRequest() { Global = global, ChanPoint = channelPoint, FeeRate = feerate }; await lndClient.UpdateChannelPolicyAsync(request); }
/** * Compare two Pairs. Callback for natural order sort. * effectively returns a-b; * @return +1, a>b, 0 a=b, -1 a<b, case insensitive */ public int compareTo(ChannelPoint b) // <--- note Pair, not Object { if (_distance > b.getDistance()) { return(1); } else if (_distance < b.getDistance()) { return(-1); } else { return(0); } } // end compareTo
private static List <ChannelPoint> Bresenham(ChannelPoint p0, ChannelPoint p1) { var result = new List <ChannelPoint>(); var dx = Math.Abs(p1.X - p0.X); var dy = Math.Abs(p1.Y - p0.Y); var dirx = Math.Sign(p1.X - p0.X); var diry = Math.Sign(p1.Y - p0.Y); result.Add(new ChannelPoint(p0.X, p0.Y)); var err = 0; var x = p0.X; var y = p0.Y; if (dy < dx) { while (x != p1.X) { err += dy; if (2 * err >= dx) { y += diry; err -= dx; result.Add(new ChannelPoint(x, y)); } x += dirx; result.Add(new ChannelPoint(x, y)); } } else { while (y != p1.Y) { err += dx; if (2 * err >= dy) { x += dirx; err -= dy; result.Add(new ChannelPoint(x, y)); } y += diry; result.Add(new ChannelPoint(x, y)); } } return(result); }
private static ChannelPoint FindClosestPoint(Channel parent, Channel child) { var childOrigin = child.Points[0]; ChannelPoint closestPoint = null; var bestDist = double.MaxValue; foreach (var point in parent.Points) { var dist = Dist(point, childOrigin); if (dist < bestDist) { closestPoint = point; bestDist = dist; } } return(closestPoint); }
public async Task <CloseStatusUpdate> CloseChannel(ChannelPoint channelPoint, bool force = false, int targetConf = 1) { var request = new CloseChannelRequest() { ChannelPoint = channelPoint, Force = force, TargetConf = targetConf }; ; using (var stream = lndClient.CloseChannel(request)) { while (await stream.ResponseStream.MoveNext()) { return(stream.ResponseStream.Current); } } return(null); }
public Channel GetChannelAt(ChannelPoint point) { var searchRadius = 10; for (var r = 1; r <= searchRadius; r++) { for (var xi = point.X - r; xi <= point.X + r; xi++) { var channel = _channelsByPoints.GetValue(new ChannelPoint(xi, point.Y + r)); if (channel != null) { return(channel); } channel = _channelsByPoints.GetValue(new ChannelPoint(xi, point.Y - r)); if (channel != null) { return(channel); } } for (var yi = point.Y - r; yi <= point.Y + r; yi++) { var channel = _channelsByPoints.GetValue(new ChannelPoint(point.X + r, yi)); if (channel != null) { return(channel); } channel = _channelsByPoints.GetValue(new ChannelPoint(point.X - r, yi)); if (channel != null) { return(channel); } } } return(null); }
private static int Dist(ChannelPoint p1, ChannelPoint p2) { return(Math.Abs(p1.X - p2.X) + Math.Abs(p1.Y - p2.Y)); }