mirror of
https://github.com/status-im/ethereumj-personal.git
synced 2025-01-10 03:45:44 +00:00
Remove redundant type casts
This commit is contained in:
parent
780393dae9
commit
6c4502150e
@ -152,7 +152,7 @@ public class BlockStore {
|
||||
createQuery("from BlockVO").list();
|
||||
|
||||
ArrayList<Block> blocks = new ArrayList<>();
|
||||
for (BlockVO blockVO : (List<BlockVO>) result) {
|
||||
for (BlockVO blockVO : result) {
|
||||
blocks.add(new Block(blockVO.getRlp()));
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ public class ContractDetails {
|
||||
|
||||
RLPList keys = (RLPList) rlpList.get(0);
|
||||
RLPList values = (RLPList) rlpList.get(1);
|
||||
RLPElement code = (RLPElement) rlpList.get(2);
|
||||
RLPElement code = rlpList.get(2);
|
||||
|
||||
if (keys.size() > 0) {
|
||||
storageKeys = new ArrayList<>();
|
||||
|
@ -135,7 +135,7 @@ public class DatabaseImpl implements Database {
|
||||
ByteArrayWrapper key = new ByteArrayWrapper(iterator.next().getKey());
|
||||
keys.add(key);
|
||||
}
|
||||
Collections.sort((List<ByteArrayWrapper>) keys);
|
||||
Collections.sort(keys);
|
||||
return keys;
|
||||
}
|
||||
}
|
@ -48,7 +48,7 @@ public class JSONHelper {
|
||||
public static void dumpState(ObjectNode statesNode, String address, AccountState state, ContractDetails details) {
|
||||
|
||||
List<DataWord> storageKeys = new ArrayList<>(details.getStorage().keySet());
|
||||
Collections.sort((List<DataWord>) storageKeys);
|
||||
Collections.sort(storageKeys);
|
||||
|
||||
ObjectNode account = statesNode.objectNode();
|
||||
ObjectNode storage = statesNode.objectNode();
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.ethereum.net.eth;
|
||||
|
||||
import org.ethereum.util.RLP;
|
||||
import org.ethereum.util.RLPItem;
|
||||
import org.ethereum.util.RLPList;
|
||||
import org.ethereum.util.Utils;
|
||||
|
||||
@ -36,7 +35,7 @@ public class GetBlocksMessage extends EthMessage {
|
||||
|
||||
blockHashes = new ArrayList<>();
|
||||
for (int i = 1; i < paramsList.size(); ++i) {
|
||||
blockHashes.add(((RLPItem) paramsList.get(i)).getRLPData());
|
||||
blockHashes.add(paramsList.get(i).getRLPData());
|
||||
}
|
||||
parsed = true;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package org.ethereum.net.eth;
|
||||
|
||||
import org.ethereum.util.ByteUtil;
|
||||
import org.ethereum.util.RLP;
|
||||
import org.ethereum.util.RLPItem;
|
||||
import org.ethereum.util.RLPList;
|
||||
|
||||
import org.spongycastle.util.encoders.Hex;
|
||||
@ -49,12 +48,12 @@ public class StatusMessage extends EthMessage {
|
||||
private void parse() {
|
||||
RLPList paramsList = (RLPList) RLP.decode2(encoded).get(0);
|
||||
|
||||
this.protocolVersion = ((RLPItem) paramsList.get(1)).getRLPData()[0];
|
||||
byte[] networkIdBytes = ((RLPItem) paramsList.get(2)).getRLPData();
|
||||
this.protocolVersion = paramsList.get(1).getRLPData()[0];
|
||||
byte[] networkIdBytes = paramsList.get(2).getRLPData();
|
||||
this.networkId = networkIdBytes == null ? 0 : networkIdBytes[0];
|
||||
this.totalDifficulty = ((RLPItem) paramsList.get(3)).getRLPData();
|
||||
this.bestHash = ((RLPItem) paramsList.get(4)).getRLPData();
|
||||
this.genesisHash = ((RLPItem) paramsList.get(5)).getRLPData();
|
||||
this.totalDifficulty = paramsList.get(3).getRLPData();
|
||||
this.bestHash = paramsList.get(4).getRLPData();
|
||||
this.genesisHash = paramsList.get(5).getRLPData();
|
||||
|
||||
parsed = true;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package org.ethereum.net.p2p;
|
||||
|
||||
import org.ethereum.net.message.ReasonCode;
|
||||
import org.ethereum.util.RLP;
|
||||
import org.ethereum.util.RLPItem;
|
||||
import org.ethereum.util.RLPList;
|
||||
|
||||
import static org.ethereum.net.message.ReasonCode.REQUESTED;
|
||||
@ -29,7 +28,7 @@ public class DisconnectMessage extends P2pMessage {
|
||||
private void parse() {
|
||||
RLPList paramsList = (RLPList) RLP.decode2(encoded).get(0);
|
||||
|
||||
byte[] reasonBytes = ((RLPItem) paramsList.get(1)).getRLPData();
|
||||
byte[] reasonBytes = paramsList.get(1).getRLPData();
|
||||
if (reasonBytes == null)
|
||||
this.reason = REQUESTED;
|
||||
else
|
||||
|
@ -4,7 +4,6 @@ import org.ethereum.net.client.Capability;
|
||||
import org.ethereum.util.ByteUtil;
|
||||
import org.ethereum.util.RLP;
|
||||
import org.ethereum.util.RLPElement;
|
||||
import org.ethereum.util.RLPItem;
|
||||
import org.ethereum.util.RLPList;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
@ -66,10 +65,10 @@ public class HelloMessage extends P2pMessage {
|
||||
// The message does not distinguish between 0 and null,
|
||||
// so we check command code for null.
|
||||
|
||||
byte[] p2pVersionBytes = ((RLPItem) paramsList.get(1)).getRLPData();
|
||||
byte[] p2pVersionBytes = paramsList.get(1).getRLPData();
|
||||
this.p2pVersion = p2pVersionBytes != null ? p2pVersionBytes[0] : 0;
|
||||
|
||||
byte[] clientIdBytes = ((RLPItem) paramsList.get(2)).getRLPData();
|
||||
byte[] clientIdBytes = paramsList.get(2).getRLPData();
|
||||
this.clientId = new String(clientIdBytes != null ? clientIdBytes : EMPTY_BYTE_ARRAY);
|
||||
|
||||
RLPList capabilityList = (RLPList) paramsList.get(3);
|
||||
@ -86,10 +85,10 @@ public class HelloMessage extends P2pMessage {
|
||||
this.capabilities.add(cap);
|
||||
}
|
||||
|
||||
byte[] peerPortBytes = ((RLPItem) paramsList.get(4)).getRLPData();
|
||||
byte[] peerPortBytes = paramsList.get(4).getRLPData();
|
||||
this.listenPort = ByteUtil.byteArrayToInt(peerPortBytes);
|
||||
|
||||
byte[] peerIdBytes = ((RLPItem) paramsList.get(5)).getRLPData();
|
||||
byte[] peerIdBytes = paramsList.get(5).getRLPData();
|
||||
this.peerId = Hex.toHexString(peerIdBytes);
|
||||
this.parsed = true;
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ public class TrieImpl implements Trie {
|
||||
public byte[] getRootHash() {
|
||||
if (root == null
|
||||
|| (root instanceof byte[] && ((byte[]) root).length == 0)
|
||||
|| (root instanceof String && "".equals((String) root))) {
|
||||
|| (root instanceof String && "".equals(root))) {
|
||||
return EMPTY_TRIE_HASH;
|
||||
} else if (root instanceof byte[]) {
|
||||
return (byte[]) this.getRoot();
|
||||
|
@ -119,11 +119,11 @@ public class RLP {
|
||||
}
|
||||
// single byte item
|
||||
if ((data[index] & 0xFF) < OFFSET_SHORT_ITEM) {
|
||||
return (byte) (data[index]);
|
||||
return data[index];
|
||||
}
|
||||
// single byte item
|
||||
if ((data[index] & 0xFF) == OFFSET_SHORT_ITEM + 1) {
|
||||
return (byte) (data[index + 1]);
|
||||
return data[index + 1];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -528,7 +528,7 @@ public class RLP {
|
||||
byte command = 0;
|
||||
int index = getFirstListElement(data, 0);
|
||||
command = data[index];
|
||||
command = ((int) (command & 0xFF) == OFFSET_SHORT_ITEM) ? 0 : command;
|
||||
command = ((command & 0xFF) == OFFSET_SHORT_ITEM) ? 0 : command;
|
||||
return command;
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class RLPList extends ArrayList<RLPElement> implements RLPElement {
|
||||
}
|
||||
System.out.print("]");
|
||||
} else {
|
||||
String hex = ByteUtil.toHexString(((RLPItem) element).getRLPData());
|
||||
String hex = ByteUtil.toHexString(element.getRLPData());
|
||||
System.out.print(hex + ", ");
|
||||
}
|
||||
}
|
||||
|
@ -691,7 +691,7 @@ public class Program {
|
||||
StringBuilder storageData = new StringBuilder();
|
||||
if (contractDetails != null) {
|
||||
List<DataWord> storageKeys = new ArrayList<>(contractDetails.getStorage().keySet());
|
||||
Collections.sort((List<DataWord>) storageKeys);
|
||||
Collections.sort(storageKeys);
|
||||
for (DataWord key : storageKeys) {
|
||||
storageData.append(" ").append(key).append(" -> ").
|
||||
append(contractDetails.getStorage().get(key)).append("\n");
|
||||
|
@ -1163,7 +1163,7 @@ public class VM {
|
||||
ContractDetails details = program.getResult().getRepository()
|
||||
.getContractDetails(program.getOwnerAddress().getLast20Bytes());
|
||||
List<DataWord> storageKeys = new ArrayList<>(details.getStorage().keySet());
|
||||
Collections.sort((List<DataWord>) storageKeys);
|
||||
Collections.sort(storageKeys);
|
||||
|
||||
for (DataWord key : storageKeys) {
|
||||
dumpLogger.trace("{} {}",
|
||||
@ -1193,7 +1193,7 @@ public class VM {
|
||||
ContractDetails details = program.getResult().getRepository()
|
||||
.getContractDetails(program.getOwnerAddress().getLast20Bytes());
|
||||
List<DataWord> storageKeys = new ArrayList<>(details.getStorage().keySet());
|
||||
Collections.sort((List<DataWord>) storageKeys);
|
||||
Collections.sort(storageKeys);
|
||||
|
||||
for (DataWord key : storageKeys) {
|
||||
dumpLogger.trace("{}: {}",
|
||||
|
@ -706,7 +706,7 @@ public class RLPTest {
|
||||
String element2 = "Lorem ipsum dolor sit amet, consectetur adipisicing elit";
|
||||
String[] test = new String[] { element1, element2 };
|
||||
String expected = "f83e83636174b8384c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e7365637465747572206164697069736963696e6720656c6974";
|
||||
byte[] encoderesult = (byte[]) RLP.encode(test);
|
||||
byte[] encoderesult = RLP.encode(test);
|
||||
assertEquals(expected, Hex.toHexString(encoderesult));
|
||||
|
||||
Object[] decodeResult = (Object[]) RLP.decode(encoderesult, 0).getDecoded();
|
||||
|
@ -117,7 +117,7 @@ public class ProgramPlayDialog extends JPanel implements ActionListener,
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
JSlider source = (JSlider) e.getSource();
|
||||
int step = (int) source.getValue();
|
||||
int step = source.getValue();
|
||||
|
||||
int i = source.getValue();
|
||||
String out = outputList.get(i);
|
||||
|
Loading…
x
Reference in New Issue
Block a user