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

bernardladenthin / BitcoinAddressFinder / #282

11 Apr 2025 04:57PM UTC coverage: 64.134% (-0.04%) from 64.17%
#282

push

bernardladenthin
Improve log messages.

8 of 9 new or added lines in 2 files covered. (88.89%)

1 existing line in 1 file now uncovered.

1148 of 1790 relevant lines covered (64.13%)

0.64 hits per line

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

83.33
/src/main/java/net/ladenthin/bitcoinaddressfinder/ProducerJavaSecretsFiles.java
1
// @formatter:off
2
/**
3
 * Copyright 2021 Bernard Ladenthin bernard.ladenthin@gmail.com
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 *    http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 */
18
// @formatter:on
19
package net.ladenthin.bitcoinaddressfinder;
20

21
import java.io.File;
22
import java.io.IOException;
23
import java.math.BigInteger;
24
import java.util.List;
25
import java.util.concurrent.atomic.AtomicReference;
26
import net.ladenthin.bitcoinaddressfinder.configuration.CProducerJavaSecretsFiles;
27
import org.bitcoinj.base.Network;
28
import org.jspecify.annotations.NonNull;
29
import org.slf4j.Logger;
30
import org.slf4j.LoggerFactory;
31

32
public class ProducerJavaSecretsFiles extends ProducerJava {
33

34
    private final Logger logger = LoggerFactory.getLogger(ProducerJavaSecretsFiles.class);
1✔
35
    
36
    private final Network network = new NetworkParameterFactory().getNetwork();
1✔
37
    
38
    private final CProducerJavaSecretsFiles producerJavaSecretsFiles;
39

40
    private final ReadStatistic readStatistic = new ReadStatistic();
1✔
41

42
    @NonNull
1✔
43
    AtomicReference<SecretsFile> currentSecretsFile = new AtomicReference<>();
44

45
    public ProducerJavaSecretsFiles(CProducerJavaSecretsFiles producerJavaSecretsFiles, Consumer consumer, KeyUtility keyUtility, KeyProducer keyProducer, BitHelper bitHelper) {
46
        super(producerJavaSecretsFiles, consumer, keyUtility, keyProducer, bitHelper);
1✔
47
        this.producerJavaSecretsFiles = producerJavaSecretsFiles;
1✔
48
    }
1✔
49
    
50
    @Override
51
    public void produceKeys() {
52
        try {
53
            FileHelper fileHelper = new FileHelper();
1✔
54
            List<File> files = fileHelper.stringsToFiles(producerJavaSecretsFiles.files);
1✔
55
            fileHelper.assertFilesExists(files);
1✔
56

57
            logger.info("Starting secrets file processing...");
1✔
58
            for (File file : files) {
1✔
59
                if (!shouldRun.get()) {
1✔
NEW
60
                    logger.info("Key production stopped by flag.");
×
UNCOV
61
                    break;
×
62
                }
63
                SecretsFile secretsFile = new SecretsFile(
1✔
64
                    network,
65
                    file,
66
                    producerJavaSecretsFiles.secretFormat,
67
                    readStatistic,
68
                    this::consumeSecrets
69
                );
70

71
                logger.info("Processing secrets file: {}", file);
1✔
72
                currentSecretsFile.set(secretsFile);
1✔
73
                secretsFile.readFile();
1✔
74
                currentSecretsFile.set(null);
1✔
75
                logger.info("Finished processing: {}", file);
1✔
76

77
                logProgress();
1✔
78
            }
1✔
79
            logger.info("All secrets files processed.");
1✔
80
        } catch (IOException e) {
×
81
            throw new RuntimeException(e);
×
82
        }
1✔
83
    }
1✔
84

85
    @Override
86
    public void processSecrets(BigInteger[] secrets) {
87
        throw new UnsupportedOperationException("Not supported yet.");
×
88
    }
89
    
90
    private void logProgress() {
91
        logger.info("Progress: Unsupported: " + readStatistic.unsupported + ". Errors: " + readStatistic.errors.size() + ". Current File progress: " + String.format("%.2f", readStatistic.currentFileProgress) + "%.");
1✔
92
    }
1✔
93

94
    @Override
95
    public void interrupt() {
96
        super.interrupt();
1✔
97
        SecretsFile secretsFile = currentSecretsFile.get();
1✔
98
        if (secretsFile != null) {
1✔
99
            secretsFile.interrupt();
×
100
        }
101
    }
1✔
102
    
103
}
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