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

Replacing deprecated decode2 function on RLP #231

Open
wants to merge 2 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
2 changes: 1 addition & 1 deletion src/main/java/co/rsk/federate/CoinbaseInformation.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public int hashCode() {
}

public static CoinbaseInformation fromRlp(byte[] input, NetworkParameters parameters) throws Exception {
RLPList rlpList = (RLPList) RLP.decode2(input).get(0);
RLPList rlpList = RLP.decodeList(input);
Transaction tx = new Transaction(parameters, rlpList.get(0).getRLPData());
Sha256Hash witnessRoot = Sha256Hash.wrap(rlpList.get(1).getRLPData());
Sha256Hash blockHash = Sha256Hash.wrap(rlpList.get(2).getRLPData());
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/co/rsk/federate/Proof.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public Proof(Sha256Hash blockHash, PartialMerkleTree partialMerkleTree) {
}

public Proof(byte[] rlpData, NetworkParameters parameters) {
RLPList rlpList = (RLPList) RLP.decode2(rlpData).get(0);
RLPList rlpList = RLP.decodeList(rlpData);
byte[] encodedHash = rlpList.get(0).getRLPData();
byte[] encodedMerkle = rlpList.get(1).getRLPData();

Expand Down Expand Up @@ -68,7 +68,7 @@ public static List<Proof> deserializeProofList(byte[] rlpData, NetworkParameters
return list;
}

RLPList rlpList = (RLPList)RLP.decode2(rlpData).get(0);
RLPList rlpList = RLP.decodeList(rlpData);

for (int k = 0; k < rlpList.size(); k++) {
RLPElement rlpElement = rlpList.get(k);
Expand All @@ -82,7 +82,7 @@ public static Map<Sha256Hash, List<Proof>> deserializeProofs(byte[] rlpData, Net
Map<Sha256Hash, List<Proof>> newProofs = new ConcurrentHashMap<>();

if (rlpData != null && rlpData.length > 0) {
RLPList rlpList = (RLPList)RLP.decode2(rlpData).get(0);
RLPList rlpList = RLP.decodeList(rlpData);
int ntxs = rlpList.size() / 2;
for (int k = 0; k < ntxs; k++) {
Sha256Hash hash = Sha256Hash.wrap(rlpList.get(k * 2).getRLPData());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public void onBlock(org.ethereum.core.Block block, List<TransactionReceipt> rece
}

private BtcTransaction convertToBtcTxFromRLPData(byte[] dataFromBtcReleaseTopic) {
RLPList dataElements = (RLPList)RLP.decode2(dataFromBtcReleaseTopic).get(0);
RLPList dataElements = RLP.decodeList(dataFromBtcReleaseTopic);

return new BtcTransaction(bridgeConstants.getBtcParams(), dataElements.get(1).getRLPData());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private BtcToRskClientFileReadResult readFromRlp(byte[] fileData, NetworkParamet
BtcToRskClientFileData data = new BtcToRskClientFileData();

try {
ArrayList<RLPElement> elements = RLP.decode2(fileData);
ArrayList<RLPElement> elements = RLP.decodeListElements(fileData);
if (elements.isEmpty()) {
return new BtcToRskClientFileReadResult(Boolean.TRUE, data);
}
Expand All @@ -87,7 +87,7 @@ private byte[] serializeCoinbaseInformation(Map<Sha256Hash, CoinbaseInformation>
}

private Map<Sha256Hash, CoinbaseInformation> deserializeCoinbaseInformation(byte[] rlpData, NetworkParameters networkParameters) throws Exception {
RLPList rlpList = (RLPList) RLP.decode2(rlpData).get(0);
RLPList rlpList = RLP.decodeList(rlpData);
Map<Sha256Hash, CoinbaseInformation> result = new HashMap<>();

for (int k = 0; k < rlpList.size(); k++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private BtcReleaseClientFileReadResult readFromRlp(byte[] fileData) {
}

try {
ArrayList<RLPElement> elements = RLP.decode2(fileData);
ArrayList<RLPElement> elements = RLP.decodeListElements(fileData);
if (elements.isEmpty()) {
return new BtcReleaseClientFileReadResult(Boolean.TRUE, data);
}
Expand All @@ -77,7 +77,7 @@ private BtcReleaseClientFileReadResult readFromRlp(byte[] fileData) {
}
// Map
byte[] mapData = rlpList.get(0).getRLPData();
RLPList mapList = (RLPList)RLP.decode2(mapData).get(0);
RLPList mapList = RLP.decodeList(mapData);
data.getReleaseHashesMap().putAll(this.deserializeReleaseHashes(mapList));
// Block hash
if (rlpList.size() == 2) {
Expand Down