@@ -0,0 +1,2151 @@
+package peergos.server;%0A%0Aimport peergos.server.util.*;%0Aimport peergos.shared.*;%0Aimport peergos.shared.cbor.*;%0Aimport peergos.shared.crypto.hash.*;%0Aimport peergos.shared.io.ipfs.cid.*;%0Aimport peergos.shared.io.ipfs.multihash.*;%0Aimport peergos.shared.user.*;%0A%0Aimport java.io.*;%0Aimport java.net.*;%0Aimport java.util.*;%0Aimport java.util.logging.*;%0A%0A/** This utility check that all of a users mutable pointers and blocks are present as far as the network can tell%0A *%0A */%0Apublic class ValidateUser %7B%0A%0A    public static void main(String%5B%5D args) throws Exception %7B%0A        Crypto crypto = Main.initCrypto();%0A        NetworkAccess network = NetworkAccess.buildJava(new URL(%22https://alpha.peergos.net%22), true).get();%0A        String username = args%5B0%5D;%0A        Optional%3CPublicKeyHash%3E identity = network.coreNode.getPublicKeyHash(username).join();%0A        Set%3CPublicKeyHash%3E ownedKeys = WriterData.getOwnedKeysRecursive(username, network.coreNode, network.mutable,%0A                network.dhtClient, network.hasher).join();%0A        for (PublicKeyHash ownedKey : ownedKeys) %7B%0A            validateWriter(identity.get(), ownedKey, network);%0A        %7D%0A    %7D%0A%0A    private static void validateWriter(PublicKeyHash owner, PublicKeyHash writer, NetworkAccess network) %7B%0A        MaybeMultihash target = network.mutable.getPointerTarget(owner, writer, network.dhtClient).join();%0A        if (! target.isPresent()) %7B%0A            Logging.LOG().log(Level.WARNING, %22Skipping unretrievable mutable pointer for: %22 + writer);%0A            return;%0A        %7D%0A%0A        validateBlock(target.get(), network);%0A    %7D%0A%0A    private static void validateBlock(Multihash target, NetworkAccess network) %7B%0A        Optional%3CCborObject%3E block = network.dhtClient.get(target).join();%0A        if (! block.isPresent())%0A            throw new IllegalStateException(%22Couldn't retrieve %22 + target);%0A%0A        List%3CMultihash%3E links = block.get().links();%0A        for (Multihash link : links) %7B%0A            if (link instanceof Cid && ((Cid) link).codec == Cid.Codec.Raw)%0A                network.dhtClient.getSize(link).join();%0A            else%0A                validateBlock(link, network);%0A        %7D%0A    %7D%0A%7D%0A

Add util to validate a user