Skip to content

Commit

Permalink
Expose chain ID in the BlockchainService plugin API (hyperledger#7702)
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel-Trintinalia <[email protected]>Signed-off-by: Chulhee lee <[email protected]>
  • Loading branch information
Gabriel-Trintinalia authored and 2fehee committed Oct 4, 2024
1 parent fbec990 commit 6341161
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- Add configuration of Consolidation Request Contract Address via genesis configuration [#7647](https://github.com/hyperledger/besu/pull/7647)
- Interrupt pending transaction processing on block creation timeout [#7673](https://github.com/hyperledger/besu/pull/7673)
- Align gas cap calculation for transaction simulation to Geth approach [#7703](https://github.com/hyperledger/besu/pull/7703)
- Expose chainId in the `BlockchainService` [7702](https://github.com/hyperledger/besu/pull/7702)

### Bug fixes
- Fix mounted data path directory permissions for besu user [#7575](https://github.com/hyperledger/besu/pull/7575)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.hyperledger.besu.plugin.data.TransactionReceipt;
import org.hyperledger.besu.plugin.services.BlockchainService;

import java.math.BigInteger;
import java.util.List;
import java.util.Optional;
import java.util.function.Supplier;
Expand Down Expand Up @@ -182,4 +183,12 @@ public BlockBody getBlockBody() {
}
};
}

@Override
public Optional<BigInteger> getChainId() {
if (protocolSchedule == null) {
return Optional.empty();
}
return protocolSchedule.getChainId();
}
}
2 changes: 1 addition & 1 deletion plugin-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Calculated : ${currentHash}
tasks.register('checkAPIChanges', FileStateChecker) {
description = "Checks that the API for the Plugin-API project does not change without deliberate thought"
files = sourceSets.main.allJava.files
knownHash = '5H+3gUzCwZtLByfnk11kf+kAPwykQ+WR+n3xWgyfsyY='
knownHash = '4jVaj9yW88nHbX0KmTR3dPQRvj9x8Pvh5E9Ry7KRT6w='
}
check.dependsOn('checkAPIChanges')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.hyperledger.besu.plugin.data.BlockHeader;
import org.hyperledger.besu.plugin.data.TransactionReceipt;

import java.math.BigInteger;
import java.util.List;
import java.util.Optional;

Expand Down Expand Up @@ -106,5 +107,11 @@ void setFinalizedBlock(Hash blockHash)
* @throws UnsupportedOperationException if the network is a PoS network
*/
void setSafeBlock(Hash blockHash) throws IllegalArgumentException, UnsupportedOperationException;
;

/**
* Get the chain id
*
* @return the chain id
*/
Optional<BigInteger> getChainId();
}

0 comments on commit 6341161

Please sign in to comment.