mirror of
https://github.com/vacp2p/status-linea-besu.git
synced 2026-01-07 21:13:56 -05:00
Add getBlockByHash to plugins API (#8413)
* Add getBlockByHash to plugins API Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Plugin hash Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> --------- Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> Signed-off-by: Matt Whitehead <matthew.whitehead@kaleido.io> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
This commit is contained in:
@@ -69,6 +69,19 @@ public class BlockchainServiceImpl implements BlockchainService {
|
||||
.map(block -> blockContext(block::getHeader, block::getBody));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets block by hash
|
||||
*
|
||||
* @param hash the block hash
|
||||
* @return the BlockContext if block exists otherwise empty
|
||||
*/
|
||||
@Override
|
||||
public Optional<BlockContext> getBlockByHash(final Hash hash) {
|
||||
return blockchain
|
||||
.getBlockByHash(hash)
|
||||
.map(block -> blockContext(block::getHeader, block::getBody));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hash getChainHeadHash() {
|
||||
return blockchain.getChainHeadHash();
|
||||
|
||||
@@ -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 = 'Qq6tGiNFfAs1JVr7xXx07h/ANxPWcFKe3cBHER43FFQ='
|
||||
knownHash = 'xK3KgzBrgVBUosaqd/je+70Ku24Vj4nm2w94E8yHuGE='
|
||||
}
|
||||
check.dependsOn('checkAPIChanges')
|
||||
|
||||
|
||||
@@ -37,6 +37,14 @@ public interface BlockchainService extends BesuService {
|
||||
*/
|
||||
Optional<BlockContext> getBlockByNumber(final long number);
|
||||
|
||||
/**
|
||||
* Gets block by hash
|
||||
*
|
||||
* @param hash the block hash
|
||||
* @return the BlockContext
|
||||
*/
|
||||
Optional<BlockContext> getBlockByHash(final Hash hash);
|
||||
|
||||
/**
|
||||
* Get the hash of the chain head
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user