Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
Log milestones at startup and other minor logging improvements (#733)
Browse files Browse the repository at this point in the history
* Log the milestone blocks in use at startup.

* Remove duplicate word "key" in log message when new key is generated.

* Don't log that mining is paused while behind chain head when mining is not enabled.
  • Loading branch information
ajsutton authored Jan 31, 2019
1 parent 867825c commit 474511b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ public void inSyncChanged(final boolean inSync) {
LOG.info("Resuming mining operations");
startAsyncMiningOperation();
} else if (!inSync) {
LOG.info("Pausing mining while behind chain head");
if (isEnabled) {
LOG.info("Pausing mining while behind chain head");
}
haltCurrentMiningOperation();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.Comparator;
import java.util.NavigableSet;
import java.util.TreeSet;
import java.util.stream.Collectors;

public class MutableProtocolSchedule<C> implements ProtocolSchedule<C> {

Expand Down Expand Up @@ -59,4 +60,12 @@ public ProtocolSpec<C> getByBlockNumber(final long number) {
}
return null;
}

public String listMilestones() {
return protocolSpecs
.stream()
.sorted(Comparator.comparing(ScheduledProtocolSpec::getBlock))
.map(spec -> spec.getSpec().getName() + ": " + spec.getBlock())
.collect(Collectors.joining(", ", "[", "]"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
import java.util.OptionalLong;
import java.util.function.Function;

public class ProtocolScheduleBuilder<C> {
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class ProtocolScheduleBuilder<C> {
private static final Logger LOG = LogManager.getLogger();
private final GenesisConfigOptions config;
private final Function<ProtocolSpecBuilder<Void>, ProtocolSpecBuilder<C>> protocolSpecAdapter;
private final int defaultChainId;
Expand Down Expand Up @@ -91,6 +94,7 @@ public ProtocolSchedule<C> createProtocolSchedule() {
config.getConstantinopleFixBlockNumber(),
MainnetProtocolSpecs.constantinopleFixDefinition(chainId));

LOG.info("Protocol schedule created with milestones: {}", protocolSchedule.listMilestones());
return protocolSchedule;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static SECP256K1.KeyPair loadKeyPair(final File keyFile) throws IOExcepti
key = SECP256K1.KeyPair.generate();
key.getPrivateKey().store(keyFile);
LOG.info(
"Generated new key key {} and stored it to {}",
"Generated new key {} and stored it to {}",
key.getPublicKey().toString(),
keyFile.getAbsolutePath());
}
Expand Down

0 comments on commit 474511b

Please sign in to comment.