-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: RA-78 Refactor LedgerBlockServiceImpl
- Loading branch information
Showing
2 changed files
with
69 additions
and
99 deletions.
There are no files selected for viewing
22 changes: 3 additions & 19 deletions
22
...c/main/java/org/cardanofoundation/rosetta/api/block/model/repository/BlockRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,24 @@ | ||
package org.cardanofoundation.rosetta.api.block.model.repository; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
import org.cardanofoundation.rosetta.api.block.model.entity.BlockEntity; | ||
import org.cardanofoundation.rosetta.api.block.model.entity.TxnEntity; | ||
|
||
|
||
public interface BlockRepository extends JpaRepository<BlockEntity, Long> { | ||
|
||
@Query(value = | ||
"SELECT b " + | ||
"FROM BlockEntity b " + | ||
"WHERE b.prev.hash IS NULL") | ||
List<BlockEntity> findGenesisBlock(); | ||
@Query(value = "SELECT b FROM BlockEntity b WHERE b.prev.hash IS NULL") | ||
Optional<BlockEntity> findGenesisBlock(); | ||
|
||
Optional<BlockEntity> findByNumber(Long blockNumber); | ||
|
||
Optional<BlockEntity> findByHash(String blockHash); | ||
|
||
Optional<BlockEntity> findByNumberAndHash(Long blockNumber, String blockHash); | ||
|
||
@Query("SELECT number FROM BlockEntity " + | ||
"ORDER BY number DESC LIMIT 1") | ||
@Query("SELECT number FROM BlockEntity ORDER BY number DESC LIMIT 1") | ||
Long findLatestBlockNumber(); | ||
|
||
@Query("SELECT tx " | ||
+ "FROM TxnEntity tx " | ||
+ "WHERE tx.txHash = :hash " | ||
+ "AND tx.block.hash = :blockHash") | ||
List<TxnEntity> findTransactionByHashAndBlock( | ||
@Param("hash") String hash, | ||
@Param("blockHash") String blockHash); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters