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

knowledgepixels / nanopub-registry / 22864180778

09 Mar 2026 04:42PM UTC coverage: 27.141% (+2.0%) from 25.137%
22864180778

Pull #75

github

web-flow
Merge 857cb3897 into 2cd5b4b8d
Pull Request #75: feat: add registry-to-registry peer sync for CHECK_NEW

166 of 674 branches covered (24.63%)

Branch coverage included in aggregate %.

544 of 1942 relevant lines covered (28.01%)

4.98 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
            try {
60
                long count = collection(Collection.PEER_STATE.toString()).countDocuments(mongoSession);
×
61
                println("peerState documents: " + count);
×
62
                MongoCursor<Document> ps = collection(Collection.PEER_STATE.toString()).find(mongoSession).cursor();
×
63
                while (ps.hasNext()) {
×
64
                    println(ps.next().toJson());
×
65
                }
66
            } catch (Exception ex) {
×
67
                println("Error: " + ex.getClass().getName() + ": " + ex.getMessage());
×
68
            }
×
69
            setRespContentType("text/plain");
×
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 TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc