Skip to content

Commit

Permalink
Add final to method params - ethereum module
Browse files Browse the repository at this point in the history
  • Loading branch information
gfukushima committed Apr 17, 2024
1 parent c8a800c commit 82fb239
Show file tree
Hide file tree
Showing 46 changed files with 178 additions and 162 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private StateGenerator(
}

public static StateGenerator create(
Spec spec,
final Spec spec,
final HashTree blockTree,
final StateAndBlockSummary rootBlockAndState,
final BlockProvider blockProvider) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public interface BlockProvider {

BlockProvider NOOP = (roots) -> SafeFuture.completedFuture(Collections.emptyMap());

static BlockProvider fromDynamicMap(Supplier<Map<Bytes32, SignedBeaconBlock>> mapSupplier) {
static BlockProvider fromDynamicMap(final Supplier<Map<Bytes32, SignedBeaconBlock>> mapSupplier) {
return (roots) -> fromMap(mapSupplier.get()).getBlocks(roots);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,24 @@ public class Eth1Address extends Bytes20 {

private final String encodedAddress;

private Eth1Address(String value) {
private Eth1Address(final String value) {
super(Bytes.fromHexString(value));
String valueWithPrefix = value;
if (!value.startsWith("0x")) {
value = "0x" + value;
valueWithPrefix = "0x" + value;
}
this.encodedAddress = toChecksumAddress(value);
validate(value);
this.encodedAddress = toChecksumAddress(valueWithPrefix);
validate(valueWithPrefix);
}

private Eth1Address(Bytes bytes) {
private Eth1Address(final Bytes bytes) {
super(bytes);
final String value = bytes.toHexString();
this.encodedAddress = toChecksumAddress(value);
validate(value);
}

private void validate(String value) {
private void validate(final String value) {
if (isMixedCase(value.substring("0x".length()))) {
checkArgument(
value.equals(encodedAddress),
Expand All @@ -56,11 +57,11 @@ private void validate(String value) {
}
}

public static Eth1Address fromBytes(Bytes value) {
public static Eth1Address fromBytes(final Bytes value) {
return new Eth1Address(value);
}

public static Eth1Address fromHexString(String value) {
public static Eth1Address fromHexString(final String value) {
try {
return new Eth1Address(value);
} catch (RuntimeException ex) {
Expand All @@ -75,7 +76,7 @@ public static Eth1Address fromHexString(String value) {
* @param value The string representation of an Ethereum address.
* @return The encoded address with mixed-case checksum.
*/
private static String toChecksumAddress(String value) {
private static String toChecksumAddress(final String value) {
final String address = value.replace("0x", "").toLowerCase(Locale.ROOT);
final String hashString =
Hash.keccak256(Bytes.wrap(address.getBytes(StandardCharsets.US_ASCII)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ public static class Builder {
private boolean forkChoiceUpdatedAlwaysSendPayloadAttributes =
DEFAULT_FORK_CHOICE_UPDATED_ALWAYS_SEND_PAYLOAD_ATTRIBUTES;

public void spec(Spec spec) {
public void spec(final Spec spec) {
this.spec = spec;
}

Expand Down Expand Up @@ -537,7 +537,7 @@ public Builder customGenesisState(final String genesisState) {
}

public Builder ignoreWeakSubjectivityPeriodEnabled(
boolean ignoreWeakSubjectivityPeriodEnabled) {
final boolean ignoreWeakSubjectivityPeriodEnabled) {
this.allowSyncOutsideWeakSubjectivityPeriod = ignoreWeakSubjectivityPeriodEnabled;
return this;
}
Expand All @@ -547,7 +547,7 @@ public Builder asyncP2pMaxThreads(final int asyncP2pMaxThreads) {
return this;
}

public Builder asyncP2pMaxQueue(Integer asyncP2pMaxQueue) {
public Builder asyncP2pMaxQueue(final Integer asyncP2pMaxQueue) {
this.asyncP2pMaxQueue = asyncP2pMaxQueue;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public class MinGenesisTimeBlockEvent {
private final UInt64 blockNumber;
private final Bytes32 blockHash;

public MinGenesisTimeBlockEvent(UInt64 timestamp, UInt64 blockNumber, Bytes32 blockHash) {
public MinGenesisTimeBlockEvent(
final UInt64 timestamp, final UInt64 blockNumber, final Bytes32 blockHash) {
this.timestamp = timestamp;
this.blockNumber = blockNumber;
this.blockHash = blockHash;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

public interface SpecConfigAltair extends SpecConfig {

static SpecConfigAltair required(SpecConfig specConfig) {
static SpecConfigAltair required(final SpecConfig specConfig) {
return specConfig
.toVersionAltair()
.orElseThrow(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

public interface SpecConfigBellatrix extends SpecConfigAltair {

static SpecConfigBellatrix required(SpecConfig specConfig) {
static SpecConfigBellatrix required(final SpecConfig specConfig) {
return specConfig
.toVersionBellatrix()
.orElseThrow(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

public interface SpecConfigCapella extends SpecConfigBellatrix {

static SpecConfigCapella required(SpecConfig specConfig) {
static SpecConfigCapella required(final SpecConfig specConfig) {
return specConfig
.toVersionCapella()
.orElseThrow(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ public class BeaconBlock
extends Container5<BeaconBlock, SszUInt64, SszUInt64, SszBytes32, SszBytes32, BeaconBlockBody>
implements BeaconBlockSummary, BlockContainer {

BeaconBlock(final BeaconBlockSchema type, TreeNode backingNode) {
BeaconBlock(final BeaconBlockSchema type, final TreeNode backingNode) {
super(type, backingNode);
}

public BeaconBlock(
BeaconBlockSchema type,
UInt64 slot,
UInt64 proposerIndex,
Bytes32 parentRoot,
Bytes32 stateRoot,
BeaconBlockBody body) {
final BeaconBlockSchema type,
final UInt64 slot,
final UInt64 proposerIndex,
final Bytes32 parentRoot,
final Bytes32 stateRoot,
final BeaconBlockBody body) {
super(
type,
SszUInt64.of(slot),
Expand All @@ -64,7 +64,7 @@ public static BeaconBlock fromGenesisState(
genesisSchema.getBeaconBlockBodySchema().createEmpty());
}

public BeaconBlock withStateRoot(Bytes32 stateRoot) {
public BeaconBlock withStateRoot(final Bytes32 stateRoot) {
return new BeaconBlock(
this.getSchema(), getSlot(), getProposerIndex(), getParentRoot(), stateRoot, getBody());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public BeaconBlockSchema(
}

@Override
public BeaconBlock createFromBackingNode(TreeNode node) {
public BeaconBlock createFromBackingNode(final TreeNode node) {
return new BeaconBlock(this, node);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public Eth1DataSchema() {
}

@Override
public Eth1Data createFromBackingNode(TreeNode node) {
public Eth1Data createFromBackingNode(final TreeNode node) {
return new Eth1Data(this, node);
}
}
Expand All @@ -49,11 +49,11 @@ public Eth1Data createFromBackingNode(TreeNode node) {
public static final Bytes32 EMPTY_DEPOSIT_ROOT =
Bytes32.fromHexString("0xd70a234731285c6804c2a4f56711ddb8c82c99740f207854891028af34e27e5e");

private Eth1Data(Eth1DataSchema type, TreeNode backingNode) {
private Eth1Data(final Eth1DataSchema type, final TreeNode backingNode) {
super(type, backingNode);
}

public Eth1Data(Bytes32 depositRoot, UInt64 depositCount, Bytes32 blockHash) {
public Eth1Data(final Bytes32 depositRoot, final UInt64 depositCount, final Bytes32 blockHash) {
super(
SSZ_SCHEMA,
SszBytes32.of(depositRoot),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
public class SignedBeaconBlock extends Container2<SignedBeaconBlock, BeaconBlock, SszSignature>
implements BeaconBlockSummary, SignedBlockContainer {

SignedBeaconBlock(SignedBeaconBlockSchema type, TreeNode backingNode) {
SignedBeaconBlock(final SignedBeaconBlockSchema type, final TreeNode backingNode) {
super(type, backingNode);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public SignedBeaconBlock create(final BeaconBlock message, final BLSSignature si
}

@Override
public SignedBeaconBlock createFromBackingNode(TreeNode node) {
public SignedBeaconBlock createFromBackingNode(final TreeNode node) {
return new SignedBeaconBlock(this, node);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

public class Transaction extends SszByteListImpl {

Transaction(TransactionSchema schema, TreeNode backingNode) {
Transaction(final TransactionSchema schema, final TreeNode backingNode) {
super(schema, backingNode);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class ExecutionPayloadElectraImpl
implements ExecutionPayloadElectra {

public ExecutionPayloadElectraImpl(
ContainerSchema19<
final ContainerSchema19<
ExecutionPayloadElectraImpl,
SszBytes32,
SszByteVector,
Expand All @@ -79,31 +79,31 @@ public ExecutionPayloadElectraImpl(
SszList<DepositReceipt>,
SszList<ExecutionLayerExit>>
schema,
TreeNode backingNode) {
final TreeNode backingNode) {
super(schema, backingNode);
}

public ExecutionPayloadElectraImpl(
ExecutionPayloadSchemaElectra schema,
SszBytes32 parentHash,
SszByteVector feeRecipient,
SszBytes32 stateRoot,
SszBytes32 receiptsRoot,
SszByteVector logsBloom,
SszBytes32 prevRandao,
SszUInt64 blockNumber,
SszUInt64 gasLimit,
SszUInt64 gasUsed,
SszUInt64 timestamp,
SszByteList extraData,
SszUInt256 baseFeePerGas,
SszBytes32 blockHash,
SszList<Transaction> transactions,
SszList<Withdrawal> withdrawals,
SszUInt64 blobGasUsed,
SszUInt64 excessBlobGas,
SszList<DepositReceipt> depositReceipts,
SszList<ExecutionLayerExit> exits) {
final ExecutionPayloadSchemaElectra schema,
final SszBytes32 parentHash,
final SszByteVector feeRecipient,
final SszBytes32 stateRoot,
final SszBytes32 receiptsRoot,
final SszByteVector logsBloom,
final SszBytes32 prevRandao,
final SszUInt64 blockNumber,
final SszUInt64 gasLimit,
final SszUInt64 gasUsed,
final SszUInt64 timestamp,
final SszByteList extraData,
final SszUInt256 baseFeePerGas,
final SszBytes32 blockHash,
final SszList<Transaction> transactions,
final SszList<Withdrawal> withdrawals,
final SszUInt64 blobGasUsed,
final SszUInt64 excessBlobGas,
final SszList<DepositReceipt> depositReceipts,
final SszList<ExecutionLayerExit> exits) {
super(
schema,
parentHash,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class ExecutionPayloadHeaderElectraImpl
implements ExecutionPayloadHeaderElectra {

protected ExecutionPayloadHeaderElectraImpl(
ContainerSchema19<
final ContainerSchema19<
ExecutionPayloadHeaderElectraImpl,
SszBytes32,
SszByteVector,
Expand All @@ -74,31 +74,31 @@ protected ExecutionPayloadHeaderElectraImpl(
SszBytes32,
SszBytes32>
schema,
TreeNode backingTree) {
final TreeNode backingTree) {
super(schema, backingTree);
}

public ExecutionPayloadHeaderElectraImpl(
ExecutionPayloadHeaderSchemaElectra schema,
SszBytes32 parentHash,
SszByteVector feeRecipient,
SszBytes32 stateRoot,
SszBytes32 receiptsRoot,
SszByteVector logsBloom,
SszBytes32 prevRandao,
SszUInt64 blockNumber,
SszUInt64 gasLimit,
SszUInt64 gasUsed,
SszUInt64 timestamp,
SszByteList extraData,
SszUInt256 baseFeePerGas,
SszBytes32 blockHash,
SszBytes32 transactionsRoot,
SszBytes32 withdrawalsRoot,
SszUInt64 blobGasUsed,
SszUInt64 excessBlobGas,
SszBytes32 depositReceiptsRoot,
SszBytes32 exitsRoot) {
final ExecutionPayloadHeaderSchemaElectra schema,
final SszBytes32 parentHash,
final SszByteVector feeRecipient,
final SszBytes32 stateRoot,
final SszBytes32 receiptsRoot,
final SszByteVector logsBloom,
final SszBytes32 prevRandao,
final SszUInt64 blockNumber,
final SszUInt64 gasLimit,
final SszUInt64 gasUsed,
final SszUInt64 timestamp,
final SszByteList extraData,
final SszUInt256 baseFeePerGas,
final SszBytes32 blockHash,
final SszBytes32 transactionsRoot,
final SszBytes32 withdrawalsRoot,
final SszUInt64 blobGasUsed,
final SszUInt64 excessBlobGas,
final SszBytes32 depositReceiptsRoot,
final SszBytes32 exitsRoot) {
super(
schema,
parentHash,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ public BeaconBlocksByRootRequestMessageSchema(final SpecConfig specConfig) {
}

@Override
public BeaconBlocksByRootRequestMessage createFromBackingNode(TreeNode node) {
public BeaconBlocksByRootRequestMessage createFromBackingNode(final TreeNode node) {
return new BeaconBlocksByRootRequestMessage(this, node);
}
}

public BeaconBlocksByRootRequestMessage(
final BeaconBlocksByRootRequestMessageSchema schema, List<Bytes32> roots) {
final BeaconBlocksByRootRequestMessageSchema schema, final List<Bytes32> roots) {
super(schema, schema.createTreeFromElements(roots.stream().map(SszBytes32::of).toList()));
}

private BeaconBlocksByRootRequestMessage(
BeaconBlocksByRootRequestMessageSchema schema, TreeNode node) {
final BeaconBlocksByRootRequestMessageSchema schema, final TreeNode node) {
super(schema, node);
}

Expand Down
Loading

0 comments on commit 82fb239

Please sign in to comment.