tSort correlated points from history4 by ascending height. - obelisk - Electrum server using libbitcoin as its backend
git clone https://git.parazyd.org/obelisk
Log
Files
Refs
README
LICENSE
---
commit b0b56496f93a1e0460fc02c0ed7308fbe4c3614a
parent 580d9c1f807b43ead6764876eae14532aaf491b8
Author: parazyd 
Date:   Fri,  9 Apr 2021 11:02:21 +0200

Sort correlated points from history4 by ascending height.

Diffstat:
  M electrumobelisk/zeromq.py           |       9 ++++++++-

1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/electrumobelisk/zeromq.py b/electrumobelisk/zeromq.py
t@@ -379,7 +379,14 @@ class Client:
         correlated_points = Client.__correlate(points)
         # self.log.debug("history points: %s", points)
         # self.log.debug("history correlated: %s", correlated_points)
-        return error_code, correlated_points
+        return error_code, self._sort_correlated_points(correlated_points)
+
+    @staticmethod
+    def _sort_correlated_points(points):
+        """Sort by ascending height"""
+        if len(points) < 2:
+            return points
+        return sorted(points, key=lambda x: list(x.values())[0]["height"])
 
     async def broadcast_transaction(self, rawtx):
         """Broadcast given raw transaction"""