Search in sources :

Example 1 with PearlDiverLocalPoW

use of cfb.pearldiver.PearlDiverLocalPoW in project run-wallet-android by runplay.

the class AutoNudger method main.

public static void main(String[] args) {
    try {
        String protocol = "";
        String host = "";
        String port = "";
        IotaAPI api = new IotaAPI.Builder().localPoW(new PearlDiverLocalPoW()).protocol(protocol).host(host).port(port).build();
        System.out.println("AutoNudger connecting to host " + api.getHost() + " Port: " + api.getPort() + " Protocol: " + api.getProtocol());
        GetNodeInfoResponse response = api.getNodeInfo();
        String seed1 = "VEEMLFEYESWZPGXPQLV9GPUVFWTBYXZNSDPXKLLQUQTGFVXRNWKJLDCBAAQKVEWWCDLXU9BGRTR9QCMS9";
        long counter = 0;
        double avgTxTime = 0;
        long totalTxTime = 0;
        while (1 == 1) {
            long yourmilliseconds = System.currentTimeMillis();
            SimpleDateFormat sdf = new SimpleDateFormat("MMM dd,yyyy HH:mm:ss");
            Date resultdate = new Date(yourmilliseconds);
            System.out.println("---------------------------------------------------------------------------------------------------------------");
            System.out.println("LatestMilestoneIndex " + response.getLatestMilestoneIndex() + " LatestSolidSubtangleMilestoneIndex " + response.getLatestSolidSubtangleMilestoneIndex());
            System.out.println("Tips " + response.getTips());
            Random r = new Random();
            String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ9";
            String addrString = "WONKYTONKY9HELLO9WORLD";
            StringBuilder stringBuilder = new StringBuilder();
            String finalString = stringBuilder.toString();
            for (int i = 0; i < 59; i++) {
                stringBuilder.append(alphabet.charAt(r.nextInt(alphabet.length())));
            }
            // addrString +=
            // "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
            addrString += stringBuilder.toString();
            String address = Checksum.addChecksum(addrString);
            // System.out.println(address);
            List<Transfer> transfers = new ArrayList<>();
            transfers.add(new Transfer(address, 0, TEST_MESSAGE, TEST_TAG));
            System.out.println("new Address : " + address);
            SendTransferResponse str = api.sendTransfer(seed1, 2, DEPTH, MIN_WEIGHT_MAGNITUDE, transfers, null, null, false, false);
            if (str.getSuccessfully() != null && str.getSuccessfully().length > 0)
                System.out.println("success? " + str.getSuccessfully()[0]);
            else
                System.out.println("success? " + "false");
            counter++;
            System.out.println("Counter tx's: " + counter);
            yourmilliseconds = System.currentTimeMillis();
            Date resultdate2 = new Date(yourmilliseconds);
            System.out.println(sdf.format(resultdate2));
            long seconds = (resultdate2.getTime() - resultdate.getTime()) / 1000;
            totalTxTime += seconds;
            avgTxTime = totalTxTime / counter;
            System.out.println("last tx time: " + seconds + " sec");
            System.out.println("average tx time: " + avgTxTime + " sec");
        }
    } catch (ArgumentException e) {
        Log.e("SPA", "" + e.getMessage());
    }
}
Also used : SendTransferResponse(jota.dto.response.SendTransferResponse) IotaAPI(jota.IotaAPI) ArrayList(java.util.ArrayList) Date(java.util.Date) PearlDiverLocalPoW(cfb.pearldiver.PearlDiverLocalPoW) Random(java.util.Random) Transfer(jota.model.Transfer) GetNodeInfoResponse(jota.dto.response.GetNodeInfoResponse) ArgumentException(jota.error.ArgumentException) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

PearlDiverLocalPoW (cfb.pearldiver.PearlDiverLocalPoW)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Random (java.util.Random)1 IotaAPI (jota.IotaAPI)1 GetNodeInfoResponse (jota.dto.response.GetNodeInfoResponse)1 SendTransferResponse (jota.dto.response.SendTransferResponse)1 ArgumentException (jota.error.ArgumentException)1 Transfer (jota.model.Transfer)1