Skip to content

Commit ccfef8b

Browse files
authored
Merge pull request #2007 from thinkAfCod/feature/add_field
add parentBeaconBlockRoot field
2 parents 9e9b5c0 + 15049ee commit ccfef8b

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

core/src/main/java/org/web3j/protocol/core/methods/response/EthBlock.java

+21
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public static class Block {
6262
private String number;
6363
private String hash;
6464
private String parentHash;
65+
private String parentBeaconBlockRoot;
6566
private String nonce;
6667
private String sha3Uncles;
6768
private String logsBloom;
@@ -93,6 +94,7 @@ public Block(
9394
String number,
9495
String hash,
9596
String parentHash,
97+
String parentBeaconBlockRoot,
9698
String nonce,
9799
String sha3Uncles,
98100
String logsBloom,
@@ -120,6 +122,7 @@ public Block(
120122
this.number = number;
121123
this.hash = hash;
122124
this.parentHash = parentHash;
125+
this.parentBeaconBlockRoot = parentBeaconBlockRoot;
123126
this.nonce = nonce;
124127
this.sha3Uncles = sha3Uncles;
125128
this.logsBloom = logsBloom;
@@ -227,6 +230,14 @@ public void setParentHash(String parentHash) {
227230
this.parentHash = parentHash;
228231
}
229232

233+
public String getParentBeaconBlockRoot() {
234+
return parentBeaconBlockRoot;
235+
}
236+
237+
public void setParentBeaconBlockRoot(String parentBeaconBlockRoot) {
238+
this.parentBeaconBlockRoot = parentBeaconBlockRoot;
239+
}
240+
230241
public BigInteger getNonce() {
231242
return Numeric.decodeQuantity(nonce);
232243
}
@@ -488,6 +499,11 @@ public boolean equals(Object o) {
488499
: block.getParentHash() != null) {
489500
return false;
490501
}
502+
if (getParentBeaconBlockRoot() != null
503+
? !getParentBeaconBlockRoot().equals(block.getParentBeaconBlockRoot())
504+
: block.getParentBeaconBlockRoot() != null) {
505+
return false;
506+
}
491507
if (getNonceRaw() != null
492508
? !getNonceRaw().equals(block.getNonceRaw())
493509
: block.getNonceRaw() != null) {
@@ -619,6 +635,11 @@ public int hashCode() {
619635
int result = getNumberRaw() != null ? getNumberRaw().hashCode() : 0;
620636
result = 31 * result + (getHash() != null ? getHash().hashCode() : 0);
621637
result = 31 * result + (getParentHash() != null ? getParentHash().hashCode() : 0);
638+
result =
639+
31 * result
640+
+ (getParentBeaconBlockRoot() != null
641+
? getParentBeaconBlockRoot().hashCode()
642+
: 0);
622643
result = 31 * result + (getNonceRaw() != null ? getNonceRaw().hashCode() : 0);
623644
result = 31 * result + (getSha3Uncles() != null ? getSha3Uncles().hashCode() : 0);
624645
result = 31 * result + (getLogsBloom() != null ? getLogsBloom().hashCode() : 0);

core/src/test/java/org/web3j/protocol/core/ResponseTest.java

+4
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ public void testEthBlockTransactionHashes() {
626626
+ " \"number\": \"0x1b4\",\n"
627627
+ " \"hash\": \"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331\",\n"
628628
+ " \"parentHash\": \"0x9646252be9520f6e71339a8df9c55e4d7619deeb018d2a3f2d21fc165dde5eb5\",\n"
629+
+ " \"parentBeaconBlockRoot\": \"0x87996eeac031318cd38ee5de92b630676da7263b697a93ff55d0ad88c142e169\",\n"
629630
+ " \"nonce\": \"0xe04d296d2460cfb8472af2c5fd05b5a214109c25688d3704aed5484f9a7792f2\",\n"
630631
+ " \"sha3Uncles\": \"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\n"
631632
+ " \"logsBloom\": \"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331\",\n"
@@ -675,6 +676,7 @@ public void testEthBlockTransactionHashes() {
675676
"0x1b4",
676677
"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
677678
"0x9646252be9520f6e71339a8df9c55e4d7619deeb018d2a3f2d21fc165dde5eb5",
679+
"0x87996eeac031318cd38ee5de92b630676da7263b697a93ff55d0ad88c142e169",
678680
"0xe04d296d2460cfb8472af2c5fd05b5a214109c25688d3704aed5484f9a7792f2",
679681
"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
680682
"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
@@ -872,6 +874,7 @@ public void testEthBlockFullTransactionsWithBlob() {
872874
+ " \"number\": \"0x1b4\",\n"
873875
+ " \"hash\": \"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331\",\n"
874876
+ " \"parentHash\": \"0x9646252be9520f6e71339a8df9c55e4d7619deeb018d2a3f2d21fc165dde5eb5\",\n"
877+
+ " \"parentBeaconBlockRoot\": \"0x87996eeac031318cd38ee5de92b630676da7263b697a93ff55d0ad88c142e169\",\n"
875878
+ " \"nonce\": \"0xe04d296d2460cfb8472af2c5fd05b5a214109c25688d3704aed5484f9a7792f2\",\n"
876879
+ " \"sha3Uncles\": \"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\n"
877880
+ " \"logsBloom\": \"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331\",\n"
@@ -950,6 +953,7 @@ public void testEthBlockFullTransactionsWithBlob() {
950953
"0x1b4",
951954
"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
952955
"0x9646252be9520f6e71339a8df9c55e4d7619deeb018d2a3f2d21fc165dde5eb5",
956+
"0x87996eeac031318cd38ee5de92b630676da7263b697a93ff55d0ad88c142e169",
953957
"0xe04d296d2460cfb8472af2c5fd05b5a214109c25688d3704aed5484f9a7792f2",
954958
"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
955959
"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",

core/src/test/java/org/web3j/protocol/core/methods/response/EthBlockTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void testEthBlockNullSize() {
2626
new EthBlock.Block(
2727
null, null, null, null, null, null, null, null, null, null, null, null,
2828
null, null, null, null, null, null, null, null, null, null, null, null,
29-
null, null, null);
29+
null, null, null, null);
3030

3131
assertEquals(ethBlock.getSize(), BigInteger.ZERO);
3232
}
@@ -36,8 +36,8 @@ public void testEthBlockNotNullSize() {
3636
EthBlock.Block ethBlock =
3737
new EthBlock.Block(
3838
null, null, null, null, null, null, null, null, null, null, null, null,
39-
null, null, null, "0x3e8", null, null, null, null, null, null, null, null,
40-
null, null, null);
39+
null, null, null, null, "0x3e8", null, null, null, null, null, null, null,
40+
null, null, null, null);
4141

4242
assertEquals(ethBlock.getSize(), BigInteger.valueOf(1000));
4343
}

0 commit comments

Comments
 (0)