-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(verifier-data-app): test address_tx_amount and calculate address…
… balance
- Loading branch information
1 parent
8c9b43f
commit 80cd765
Showing
30 changed files
with
1,013 additions
and
75 deletions.
There are no files selected for viewing
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
102 changes: 51 additions & 51 deletions
102
...ava/org/cardanofoundation/ledgersync/verifier/data/app/config/DbSyncDatasourceConfig.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,51 +1,51 @@ | ||
package org.cardanofoundation.ledgersync.verifier.data.app.config; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories; | ||
import org.springframework.orm.jpa.JpaTransactionManager; | ||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; | ||
import org.springframework.transaction.PlatformTransactionManager; | ||
import org.springframework.transaction.annotation.EnableTransactionManagement; | ||
|
||
import javax.sql.DataSource; | ||
import java.util.Objects; | ||
|
||
@Configuration | ||
@EnableTransactionManagement | ||
@EnableJpaRepositories( | ||
entityManagerFactoryRef = "dbSyncEntityManagerFactory", | ||
transactionManagerRef = "dbSyncTransactionManager", | ||
basePackages = {"org.cardanofoundation.ledgersync.verifier.data.app.repository.dbsync"}) | ||
@RequiredArgsConstructor | ||
public class DbSyncDatasourceConfig { | ||
|
||
private final MultiDataSourceProperties multiDataSourceProperties; | ||
|
||
@Bean(name = "dbSyncDataSource") | ||
public DataSource ledgerSyncDataSource() { | ||
return multiDataSourceProperties.buildDataSource( | ||
multiDataSourceProperties.getDatasourceDbSync()); | ||
} | ||
|
||
@Bean(name = "dbSyncEntityManagerFactory") | ||
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean( | ||
EntityManagerFactoryBuilder builder, @Qualifier("dbSyncDataSource") DataSource dataSource) { | ||
return builder | ||
.dataSource(dataSource) | ||
.packages( | ||
"org.cardanofoundation.ledgersync.verifier.data.app.entity.dbsync") | ||
.build(); | ||
} | ||
|
||
@Bean(name = "dbSyncTransactionManager") | ||
public PlatformTransactionManager dbSyncTransactionManager( | ||
@Qualifier("dbSyncEntityManagerFactory") | ||
LocalContainerEntityManagerFactoryBean ledgerSyncEntityManagerFactory) { | ||
return new JpaTransactionManager( | ||
Objects.requireNonNull(ledgerSyncEntityManagerFactory.getObject())); | ||
} | ||
} | ||
//package org.cardanofoundation.ledgersync.verifier.data.app.config; | ||
// | ||
//import lombok.RequiredArgsConstructor; | ||
//import org.springframework.beans.factory.annotation.Qualifier; | ||
//import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; | ||
//import org.springframework.context.annotation.Bean; | ||
//import org.springframework.context.annotation.Configuration; | ||
//import org.springframework.data.jpa.repository.config.EnableJpaRepositories; | ||
//import org.springframework.orm.jpa.JpaTransactionManager; | ||
//import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; | ||
//import org.springframework.transaction.PlatformTransactionManager; | ||
//import org.springframework.transaction.annotation.EnableTransactionManagement; | ||
// | ||
//import javax.sql.DataSource; | ||
//import java.util.Objects; | ||
// | ||
//@Configuration | ||
//@EnableTransactionManagement | ||
//@EnableJpaRepositories( | ||
// entityManagerFactoryRef = "dbSyncEntityManagerFactory", | ||
// transactionManagerRef = "dbSyncTransactionManager", | ||
// basePackages = {"org.cardanofoundation.ledgersync.verifier.data.app.repository.dbsync"}) | ||
//@RequiredArgsConstructor | ||
//public class DbSyncDatasourceConfig { | ||
// | ||
// private final MultiDataSourceProperties multiDataSourceProperties; | ||
// | ||
// @Bean(name = "dbSyncDataSource") | ||
// public DataSource ledgerSyncDataSource() { | ||
// return multiDataSourceProperties.buildDataSource( | ||
// multiDataSourceProperties.getDatasourceDbSync()); | ||
// } | ||
// | ||
// @Bean(name = "dbSyncEntityManagerFactory") | ||
// public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean( | ||
// EntityManagerFactoryBuilder builder, @Qualifier("dbSyncDataSource") DataSource dataSource) { | ||
// return builder | ||
// .dataSource(dataSource) | ||
// .packages( | ||
// "org.cardanofoundation.ledgersync.verifier.data.app.entity.dbsync") | ||
// .build(); | ||
// } | ||
// | ||
// @Bean(name = "dbSyncTransactionManager") | ||
// public PlatformTransactionManager dbSyncTransactionManager( | ||
// @Qualifier("dbSyncEntityManagerFactory") | ||
// LocalContainerEntityManagerFactoryBean ledgerSyncEntityManagerFactory) { | ||
// return new JpaTransactionManager( | ||
// Objects.requireNonNull(ledgerSyncEntityManagerFactory.getObject())); | ||
// } | ||
//} |
57 changes: 57 additions & 0 deletions
57
.../src/main/java/org/cardanofoundation/ledgersync/verifier/data/app/config/KoiosConfig.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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package org.cardanofoundation.ledgersync.verifier.data.app.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import rest.koios.client.backend.api.address.AddressService; | ||
import rest.koios.client.backend.api.block.BlockService; | ||
import rest.koios.client.backend.api.transactions.TransactionsService; | ||
import rest.koios.client.backend.factory.BackendFactory; | ||
import rest.koios.client.backend.factory.BackendService; | ||
|
||
@Configuration | ||
public class KoiosConfig { | ||
|
||
/** | ||
* Creates a bean for accessing the Koios preprod backend service. | ||
* | ||
* @return BackendService instance for Koios preprod. | ||
*/ | ||
@Bean | ||
public BackendService createBackendServiceBean() { | ||
return BackendFactory.getKoiosPreprodService(); | ||
} | ||
|
||
/** | ||
* Creates a bean for accessing the address service provided by the backend service. | ||
* | ||
* @param backendService The backend service instance. | ||
* @return AddressService instance for interacting with address-related data. | ||
*/ | ||
@Bean | ||
public AddressService createAddressServiceBean(BackendService backendService) { | ||
return backendService.getAddressService(); | ||
} | ||
|
||
/** | ||
* Creates a bean for accessing the transactions service provided by the backend service. | ||
* | ||
* @param backendService The backend service instance. | ||
* @return TransactionsService instance for interacting with transaction-related data. | ||
*/ | ||
@Bean | ||
public TransactionsService createTransactionServiceBean(BackendService backendService) { | ||
return backendService.getTransactionsService(); | ||
} | ||
|
||
/** | ||
* Creates a bean for accessing the block service provided by the backend service. | ||
* | ||
* @param backendService The backend service instance. | ||
* @return BlockService instance for interacting with block-related data. | ||
*/ | ||
@Bean | ||
public BlockService createBlockServiceBean(BackendService backendService) { | ||
return backendService.getBlockService(); | ||
} | ||
} | ||
|
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
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
11 changes: 11 additions & 0 deletions
11
...a-app/src/main/java/org/cardanofoundation/ledgersync/verifier/data/app/constant/Unit.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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.cardanofoundation.ledgersync.verifier.data.app.constant; | ||
|
||
/** | ||
* Constants for unit values. | ||
*/ | ||
public class Unit { | ||
/** | ||
* The unit value for Lovelace. | ||
*/ | ||
public static final String LOVELACE = "lovelace"; | ||
} |
52 changes: 52 additions & 0 deletions
52
...org/cardanofoundation/ledgersync/verifier/data/app/entity/ledgersync/AddressTxAmount.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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.cardanofoundation.ledgersync.verifier.data.app.entity.ledgersync; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.*; | ||
import org.hibernate.annotations.DynamicUpdate; | ||
|
||
import java.math.BigInteger; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
@Entity | ||
@Table(name = "address_tx_amount") | ||
@IdClass(AddressTxAmountId.class) | ||
@DynamicUpdate | ||
public class AddressTxAmount { | ||
@Id | ||
@Column(name = "address") | ||
private String address; | ||
|
||
@Id | ||
@Column(name = "unit") | ||
private String unit; | ||
|
||
@Id | ||
@Column(name = "tx_hash") | ||
private String txHash; | ||
|
||
@Column(name = "slot") | ||
private Long slot; | ||
|
||
@Column(name = "quantity") | ||
private BigInteger quantity; | ||
|
||
//Only set if address doesn't fit in ownerAddr field. Required for few Byron Era addr | ||
@Column(name = "addr_full") | ||
private String addrFull; | ||
|
||
@Column(name = "stake_address") | ||
private String stakeAddress; | ||
|
||
@Column(name = "epoch") | ||
private Integer epoch; | ||
|
||
@Column(name = "block") | ||
private Long blockNumber; | ||
|
||
@Column(name = "block_time") | ||
private Long blockTime; | ||
} | ||
|
20 changes: 20 additions & 0 deletions
20
...g/cardanofoundation/ledgersync/verifier/data/app/entity/ledgersync/AddressTxAmountId.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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.cardanofoundation.ledgersync.verifier.data.app.entity.ledgersync; | ||
|
||
import jakarta.persistence.Column; | ||
import lombok.*; | ||
|
||
import java.io.Serializable; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@EqualsAndHashCode | ||
@Builder | ||
public class AddressTxAmountId implements Serializable { | ||
@Column(name = "address") | ||
private String address; | ||
@Column(name = "unit") | ||
private String unit; | ||
@Column(name = "tx_hash") | ||
private String txHash; | ||
} |
22 changes: 22 additions & 0 deletions
22
...cardanofoundation/ledgersync/verifier/data/app/mapper/AddressBalanceComparisonMapper.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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.cardanofoundation.ledgersync.verifier.data.app.mapper; | ||
|
||
import org.cardanofoundation.ledgersync.verifier.data.app.model.AddressBalanceComparison; | ||
import org.cardanofoundation.ledgersync.verifier.data.app.model.AddressBalanceComparisonKey; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* Interface for mapping address balance comparisons. | ||
* @param <T> The type of source data. | ||
*/ | ||
@Component | ||
public interface AddressBalanceComparisonMapper<T> { | ||
/** | ||
* Builds a map of address balance comparisons. | ||
* @param source The source data list. | ||
* @return A map of address balance comparisons. | ||
*/ | ||
Map<AddressBalanceComparisonKey, AddressBalanceComparison> buildMap(List<T> source); | ||
} |
Oops, something went wrong.