• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

knowledgepixels / nanopub-registry / 22870977169

09 Mar 2026 07:28PM UTC coverage: 27.117% (+1.6%) from 25.557%
22870977169

push

github

web-flow
Merge pull request #75 from knowledgepixels/74-peer-registry-sync

feat: add registry-to-registry peer sync for CHECK_NEW

166 of 676 branches covered (24.56%)

Branch coverage included in aggregate %.

545 of 1946 relevant lines covered (28.01%)

4.97 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
src/main/java/com/knowledgepixels/registry/DebugPage.java
1
package com.knowledgepixels.registry;
2

3
import com.mongodb.client.ClientSession;
4
import com.mongodb.client.MongoCursor;
5
import io.vertx.ext.web.RoutingContext;
6
import org.bson.Document;
7

8
import java.io.IOException;
9

10
import static com.knowledgepixels.registry.RegistryDB.collection;
11
import static com.mongodb.client.model.Indexes.ascending;
12

13
public class DebugPage extends Page {
14

15
    public static void show(RoutingContext context) {
16
        DebugPage page;
17
        try (ClientSession s = RegistryDB.getClient().startSession()) {
×
18
            s.startTransaction();
×
19
            page = new DebugPage(s, context);
×
20
            page.show();
×
21
        } catch (IOException ex) {
×
22
            ex.printStackTrace();
×
23
        } finally {
24
            context.response().end();
×
25
            // TODO Clean-up here?
26
        }
27
    }
×
28

29
    private DebugPage(ClientSession mongoSession, RoutingContext context) {
30
        super(mongoSession, context);
×
31
    }
×
32

33
    protected void show() throws IOException {
34
        RoutingContext c = getContext();
×
35

36
        if (getRequestString().matches("/debug/trustPaths")) {
×
37
            String counterString = c.request().getParam("trustStateCounter");
×
38
            if (counterString == null) {
×
39
                print(getTrustPathsTxt(mongoSession));
×
40
            } else {
41
                Long counter = Long.parseLong(counterString);
×
42
                print(RegistryDB.getOne(mongoSession, "debug_trustPaths", new Document("trustStateCounter", counter)).getString("trustStateTxt"));
×
43
            }
44
            setRespContentType("text/plain");
×
45
        } else if (getRequestString().matches("/debug/endorsements")) {
×
46
            MongoCursor<Document> tp = collection("endorsements").find(mongoSession).cursor();
×
47
            while (tp.hasNext()) {
×
48
                Document d = tp.next();
×
49
                println(d.get("agent") + ">" + d.get("pubkey") + " " + d.get("endorsedNanopub") + " " + d.get("source") + " (" + d.get("status") + ")");
×
50
            }
×
51
            setRespContentType("text/plain");
×
52
        } else if (getRequestString().matches("/debug/accounts")) {
×
53
            MongoCursor<Document> tp = collection("accounts").find(mongoSession).cursor();
×
54
            while (tp.hasNext()) {
×
55
                Document d = tp.next();
×
56
                println(d.getString("agent") + ">" + d.get("pubkey") + " " + d.get("depth") + " (" + d.get("status") + ")");
×
57
            }
×
58
        } else if (getRequestString().matches("/debug/peerState")) {
×
59
            setRespContentType("text/plain");
×
60
            try {
61
                long count = collection(Collection.PEER_STATE.toString()).countDocuments(mongoSession);
×
62
                println("peerState documents: " + count);
×
63
                MongoCursor<Document> ps = collection(Collection.PEER_STATE.toString()).find(mongoSession).cursor();
×
64
                while (ps.hasNext()) {
×
65
                    println(ps.next().toJson());
×
66
                }
67
            } catch (Exception ex) {
×
68
                println("Error: " + ex.getClass().getName() + ": " + ex.getMessage());
×
69
            }
×
70
        } else {
71
            c.response().setStatusCode(400).setStatusMessage("Invalid request: " + getFullRequest());
×
72
        }
73
    }
×
74

75
    public static String getTrustPathsTxt(ClientSession mongoSession) {
76
        String s = "";
×
77
        MongoCursor<Document> tp = collection("trustPaths").find(mongoSession).sort(ascending("_id")).cursor();
×
78
        while (tp.hasNext()) {
×
79
            Document d = tp.next();
×
80
            String path = d.getString("_id");
×
81
            path = path.replace(" ", " > ");
×
82
            if (d.getString("type").equals("extended")) {
×
83
                path = path.replaceFirst(" > ([^ ]+)$", " ~ $1");
×
84
            }
85
            s += path + "\n";
×
86
        }
×
87
        return s;
×
88
    }
89

90
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc