Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lgtm: part6 #161

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 15 additions & 23 deletions core/src/main/java/org/bitcoinj/governance/GovernanceVote.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,18 @@ public enum VoteOutcome {
VOTE_OUTCOME_NO(2),
VOTE_OUTCOME_ABSTAIN(3);

int value;
final int value;
VoteOutcome(int value) {
this.value = value;
getMappings().put(value, this);
}

private static java.util.HashMap<Integer, VoteOutcome> mappings;
private static final class MappingsHolder {
static final java.util.HashMap<Integer, VoteOutcome> mappings = new java.util.HashMap<>();
}

private static java.util.HashMap<Integer, VoteOutcome> getMappings() {
if (mappings == null) {
synchronized (VoteOutcome.class) {
if (mappings == null) {
mappings = new java.util.HashMap<Integer, VoteOutcome>();
}
}
}
return mappings;
return MappingsHolder.mappings;
}

public int getValue() {
Expand All @@ -69,7 +65,7 @@ public int getValue() {
public static VoteOutcome fromValue(int value) {
return getMappings().get(value);
}
};
}


// SIGNAL VARIOUS THINGS TO HAPPEN:
Expand Down Expand Up @@ -111,22 +107,18 @@ public enum VoteSignal {
VOTE_SIGNAL_CUSTOM19(34),
VOTE_SIGNAL_CUSTOM20(35);

int value;
final int value;
VoteSignal(int value) {
this.value = value;
getMappings().put(value, this);
}

private static java.util.HashMap<Integer, VoteSignal> mappings;
private static final class MappingsHolder {
static final java.util.HashMap<Integer, VoteSignal> mappings = new java.util.HashMap<>();
}

private static java.util.HashMap<Integer, VoteSignal> getMappings() {
if (mappings == null) {
synchronized (VoteSignal.class) {
if (mappings == null) {
mappings = new java.util.HashMap<Integer, VoteSignal>();
}
}
}
return mappings;
return MappingsHolder.mappings;
}

public int getValue() {
Expand All @@ -136,7 +128,7 @@ public int getValue() {
public static VoteSignal fromValue(int value) {
return getMappings().get(value);
}
};
}


static final int MAX_SUPPORTED_VOTE_SIGNAL = VOTE_SIGNAL_ENDORSED.getValue();
Expand Down Expand Up @@ -411,7 +403,7 @@ public boolean checkSignature(PublicKey pubKeyMasternode) {
String strMessage = masternodeOutpoint.toStringShort() + "|" + nParentHash.toString() + "|" + nVoteSignal + "|" + nVoteOutcome + "|" + nTime;

if (!MessageSigner.verifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
log.info("gobject", "CGovernanceVote::IsValid -- VerifyMessage() failed, error: {}", strError);
log.info("CGovernanceVote::IsValid -- VerifyMessage() failed, error: {}", strError);
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public synchronized ByteString maybeGetTag(String tag) {
}

@Override
public ByteString getTag(String tag) {
public synchronized ByteString getTag(String tag) {
ByteString b = maybeGetTag(tag);
if (b == null)
throw new IllegalArgumentException("Unknown tag " + tag);
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/java/org/bitcoinj/utils/BtcAutoFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,8 @@ Subtract each of (a), (b) and (c) from the true value, and choose the
@Override
public String toString() { return "Auto-format " + pattern(); }

@Override
public int hashCode() {
return pattern().hashCode();
}
}
2 changes: 2 additions & 0 deletions lgtm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
queries:
- exclude: java/weak-cryptographic-algorithm
Loading