mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-11-02 05:27:17 +00:00
Convert to local variables.
This commit is contained in:
committed by
Andreas Schildbach
parent
dbda2b9280
commit
a1c0e00c5f
@@ -15,7 +15,6 @@ public class AddressMessage extends Message {
|
|||||||
private static final long serialVersionUID = 8058283864924679460L;
|
private static final long serialVersionUID = 8058283864924679460L;
|
||||||
private static final long MAX_ADDRESSES = 1024;
|
private static final long MAX_ADDRESSES = 1024;
|
||||||
private List<PeerAddress> addresses;
|
private List<PeerAddress> addresses;
|
||||||
private transient long numAddresses = -1;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contruct a new 'addr' message.
|
* Contruct a new 'addr' message.
|
||||||
@@ -62,7 +61,7 @@ public class AddressMessage extends Message {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
void parse() throws ProtocolException {
|
void parse() throws ProtocolException {
|
||||||
numAddresses = readVarInt();
|
long numAddresses = readVarInt();
|
||||||
// Guard against ultra large messages that will crash us.
|
// Guard against ultra large messages that will crash us.
|
||||||
if (numAddresses > MAX_ADDRESSES)
|
if (numAddresses > MAX_ADDRESSES)
|
||||||
throw new ProtocolException("Address message too large.");
|
throw new ProtocolException("Address message too large.");
|
||||||
|
|||||||
@@ -44,9 +44,7 @@ public class AlertMessage extends Message {
|
|||||||
private Date expiration;
|
private Date expiration;
|
||||||
private long id;
|
private long id;
|
||||||
private long cancel;
|
private long cancel;
|
||||||
private Set<Long> cancelSet;
|
|
||||||
private long minVer, maxVer;
|
private long minVer, maxVer;
|
||||||
private Set<String> matchingSubVers;
|
|
||||||
private long priority;
|
private long priority;
|
||||||
private String comment, statusBar, reserved;
|
private String comment, statusBar, reserved;
|
||||||
|
|
||||||
@@ -86,7 +84,7 @@ public class AlertMessage extends Message {
|
|||||||
}
|
}
|
||||||
// Using a hashset here is very inefficient given that this will normally be only one item. But Java doesn't
|
// Using a hashset here is very inefficient given that this will normally be only one item. But Java doesn't
|
||||||
// make it easy to do better. What we really want is just an array-backed set.
|
// make it easy to do better. What we really want is just an array-backed set.
|
||||||
cancelSet = new HashSet<Long>((int)cancelSetSize);
|
Set<Long> cancelSet = new HashSet<Long>((int) cancelSetSize);
|
||||||
for (long i = 0; i < cancelSetSize; i++) {
|
for (long i = 0; i < cancelSetSize; i++) {
|
||||||
cancelSet.add(readUint32());
|
cancelSet.add(readUint32());
|
||||||
}
|
}
|
||||||
@@ -97,7 +95,7 @@ public class AlertMessage extends Message {
|
|||||||
if (subverSetSize < 0 || subverSetSize > MAX_SET_SIZE) {
|
if (subverSetSize < 0 || subverSetSize > MAX_SET_SIZE) {
|
||||||
throw new ProtocolException("Bad subver set size: " + subverSetSize);
|
throw new ProtocolException("Bad subver set size: " + subverSetSize);
|
||||||
}
|
}
|
||||||
matchingSubVers = new HashSet<String>((int)subverSetSize);
|
Set<String> matchingSubVers = new HashSet<String>((int) subverSetSize);
|
||||||
for (long i = 0; i < subverSetSize; i++) {
|
for (long i = 0; i < subverSetSize; i++) {
|
||||||
matchingSubVers.add(readStr());
|
matchingSubVers.add(readStr());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ import java.util.concurrent.Callable;
|
|||||||
public class PaymentSession {
|
public class PaymentSession {
|
||||||
private static ListeningExecutorService executor = Threading.THREAD_POOL;
|
private static ListeningExecutorService executor = Threading.THREAD_POOL;
|
||||||
private NetworkParameters params;
|
private NetworkParameters params;
|
||||||
private final TrustStoreLoader trustStoreLoader;
|
|
||||||
private Protos.PaymentRequest paymentRequest;
|
private Protos.PaymentRequest paymentRequest;
|
||||||
private Protos.PaymentDetails paymentDetails;
|
private Protos.PaymentDetails paymentDetails;
|
||||||
private Coin totalValue = Coin.ZERO;
|
private Coin totalValue = Coin.ZERO;
|
||||||
@@ -202,11 +201,11 @@ public class PaymentSession {
|
|||||||
* If trustStoreLoader is null, the system default trust store is used.
|
* If trustStoreLoader is null, the system default trust store is used.
|
||||||
*/
|
*/
|
||||||
public PaymentSession(Protos.PaymentRequest request, boolean verifyPki, @Nullable final TrustStoreLoader trustStoreLoader) throws PaymentProtocolException {
|
public PaymentSession(Protos.PaymentRequest request, boolean verifyPki, @Nullable final TrustStoreLoader trustStoreLoader) throws PaymentProtocolException {
|
||||||
this.trustStoreLoader = trustStoreLoader != null ? trustStoreLoader : new TrustStoreLoader.DefaultTrustStoreLoader();
|
TrustStoreLoader nonNullTrustStoreLoader = trustStoreLoader != null ? trustStoreLoader : new TrustStoreLoader.DefaultTrustStoreLoader();
|
||||||
parsePaymentRequest(request);
|
parsePaymentRequest(request);
|
||||||
if (verifyPki) {
|
if (verifyPki) {
|
||||||
try {
|
try {
|
||||||
pkiVerificationData = PaymentProtocol.verifyPaymentRequestPki(request, this.trustStoreLoader.getKeyStore());
|
pkiVerificationData = PaymentProtocol.verifyPaymentRequestPki(request, nonNullTrustStoreLoader.getKeyStore());
|
||||||
} catch (IOException x) {
|
} catch (IOException x) {
|
||||||
throw new PaymentProtocolException(x);
|
throw new PaymentProtocolException(x);
|
||||||
} catch (KeyStoreException x) {
|
} catch (KeyStoreException x) {
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ public class BitcoindComparisonTool {
|
|||||||
private static final Logger log = LoggerFactory.getLogger(BitcoindComparisonTool.class);
|
private static final Logger log = LoggerFactory.getLogger(BitcoindComparisonTool.class);
|
||||||
|
|
||||||
private static NetworkParameters params;
|
private static NetworkParameters params;
|
||||||
private static FullPrunedBlockStore store;
|
|
||||||
private static FullPrunedBlockChain chain;
|
private static FullPrunedBlockChain chain;
|
||||||
private static Sha256Hash bitcoindChainHead;
|
private static Sha256Hash bitcoindChainHead;
|
||||||
private static volatile InventoryMessage mostRecentInv = null;
|
private static volatile InventoryMessage mostRecentInv = null;
|
||||||
@@ -74,8 +73,8 @@ public class BitcoindComparisonTool {
|
|||||||
final Iterator<Block> blocks = new BlockFileLoader(params, Arrays.asList(blockFile));
|
final Iterator<Block> blocks = new BlockFileLoader(params, Arrays.asList(blockFile));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
store = new H2FullPrunedBlockStore(params, args.length > 0 ? args[0] : "BitcoindComparisonTool", blockList.maximumReorgBlockCount);
|
H2FullPrunedBlockStore store = new H2FullPrunedBlockStore(params, args.length > 0 ? args[0] : "BitcoindComparisonTool", blockList.maximumReorgBlockCount);
|
||||||
((H2FullPrunedBlockStore)store).resetStore();
|
store.resetStore();
|
||||||
//store = new MemoryFullPrunedBlockStore(params, blockList.maximumReorgBlockCount);
|
//store = new MemoryFullPrunedBlockStore(params, blockList.maximumReorgBlockCount);
|
||||||
chain = new FullPrunedBlockChain(params, store);
|
chain = new FullPrunedBlockChain(params, store);
|
||||||
} catch (BlockStoreException e) {
|
} catch (BlockStoreException e) {
|
||||||
|
|||||||
@@ -50,8 +50,6 @@ public class ChainSplitTest {
|
|||||||
private Address coinsTo;
|
private Address coinsTo;
|
||||||
private Address coinsTo2;
|
private Address coinsTo2;
|
||||||
private Address someOtherGuy;
|
private Address someOtherGuy;
|
||||||
private MemoryBlockStore blockStore;
|
|
||||||
private Context context;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
@@ -59,8 +57,8 @@ public class ChainSplitTest {
|
|||||||
Utils.setMockClock(); // Use mock clock
|
Utils.setMockClock(); // Use mock clock
|
||||||
Wallet.SendRequest.DEFAULT_FEE_PER_KB = Coin.ZERO;
|
Wallet.SendRequest.DEFAULT_FEE_PER_KB = Coin.ZERO;
|
||||||
unitTestParams = UnitTestParams.get();
|
unitTestParams = UnitTestParams.get();
|
||||||
context = new Context(unitTestParams);
|
Context context = new Context(unitTestParams);
|
||||||
blockStore = new MemoryBlockStore(unitTestParams);
|
MemoryBlockStore blockStore = new MemoryBlockStore(unitTestParams);
|
||||||
wallet = new Wallet(context);
|
wallet = new Wallet(context);
|
||||||
ECKey key1 = wallet.freshReceiveKey();
|
ECKey key1 = wallet.freshReceiveKey();
|
||||||
ECKey key2 = wallet.freshReceiveKey();
|
ECKey key2 = wallet.freshReceiveKey();
|
||||||
|
|||||||
@@ -58,8 +58,6 @@ import static org.junit.Assert.*;
|
|||||||
public class ECKeyTest {
|
public class ECKeyTest {
|
||||||
private static final Logger log = LoggerFactory.getLogger(ECKeyTest.class);
|
private static final Logger log = LoggerFactory.getLogger(ECKeyTest.class);
|
||||||
|
|
||||||
private SecureRandom secureRandom;
|
|
||||||
|
|
||||||
private KeyCrypter keyCrypter;
|
private KeyCrypter keyCrypter;
|
||||||
|
|
||||||
private static CharSequence PASSWORD1 = "my hovercraft has eels";
|
private static CharSequence PASSWORD1 = "my hovercraft has eels";
|
||||||
@@ -67,7 +65,7 @@ public class ECKeyTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
secureRandom = new SecureRandom();
|
SecureRandom secureRandom = new SecureRandom();
|
||||||
|
|
||||||
byte[] salt = new byte[KeyCrypterScrypt.SALT_LENGTH];
|
byte[] salt = new byte[KeyCrypterScrypt.SALT_LENGTH];
|
||||||
secureRandom.nextBytes(salt);
|
secureRandom.nextBytes(salt);
|
||||||
|
|||||||
@@ -62,8 +62,6 @@ public class LazyParseByteCacheTest {
|
|||||||
"00 8b 48 30 45 02 21 00 f3 58 1e 19 72 ae 8a c7" +
|
"00 8b 48 30 45 02 21 00 f3 58 1e 19 72 ae 8a c7" +
|
||||||
"c7 36 7a 7a 25 3b c1 13 52 23 ad b9 a4 68 bb 3a");
|
"c7 36 7a 7a 25 3b c1 13 52 23 ad b9 a4 68 bb 3a");
|
||||||
|
|
||||||
private Context context;
|
|
||||||
private Wallet wallet;
|
|
||||||
private BlockStore blockStore;
|
private BlockStore blockStore;
|
||||||
private NetworkParameters unitTestParams;
|
private NetworkParameters unitTestParams;
|
||||||
|
|
||||||
@@ -83,8 +81,8 @@ public class LazyParseByteCacheTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
unitTestParams = UnitTestParams.get();
|
unitTestParams = UnitTestParams.get();
|
||||||
context = new Context(unitTestParams);
|
Context context = new Context(unitTestParams);
|
||||||
wallet = new Wallet(context);
|
Wallet wallet = new Wallet(context);
|
||||||
wallet.freshReceiveKey();
|
wallet.freshReceiveKey();
|
||||||
|
|
||||||
resetBlockStore();
|
resetBlockStore();
|
||||||
|
|||||||
Reference in New Issue
Block a user