Skip to content

Commit 27e873b

Browse files
chore: remove code related to old account balance processing
1 parent affdc6e commit 27e873b

26 files changed

+60
-2283
lines changed

application/src/main/java/org/cardanofoundation/ledgersync/aggregate/AggregatedAddressBalance.java

Lines changed: 0 additions & 100 deletions
This file was deleted.

application/src/main/java/org/cardanofoundation/ledgersync/aggregate/AggregatedBatchBlockData.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
1818
public class AggregatedBatchBlockData {
1919

20-
// Key is address (Bech32 or Base58 format)
21-
Map<String, AggregatedAddressBalance> aggregatedAddressBalanceMap;
22-
2320
// Key is stake address hex, value is first appeared tx hash
2421
Map<String, String> stakeAddressTxHashMap;
2522

@@ -32,7 +29,6 @@ public class AggregatedBatchBlockData {
3229
Map<String, AggregatedBlock> aggregatedBlockMap;
3330

3431
public AggregatedBatchBlockData() {
35-
aggregatedAddressBalanceMap = new ConcurrentHashMap<>();
3632
stakeAddressTxHashMap = new ConcurrentHashMap<>();
3733
notMintedAssetFingerprintTxHashSet = new LinkedHashSet<>();
3834
fingerprintFirstAppearedMap = new ConcurrentHashMap<>();
@@ -42,7 +38,6 @@ public AggregatedBatchBlockData() {
4238

4339
// This method must be called every batch saving
4440
public void clear() {
45-
aggregatedAddressBalanceMap.clear();
4641
stakeAddressTxHashMap.clear();
4742
notMintedAssetFingerprintTxHashSet.clear();
4843
fingerprintFirstAppearedMap.clear();

application/src/main/java/org/cardanofoundation/ledgersync/repository/AddressRepository.java

Lines changed: 0 additions & 33 deletions
This file was deleted.

application/src/main/java/org/cardanofoundation/ledgersync/repository/AddressTokenBalanceRepository.java

Lines changed: 0 additions & 11 deletions
This file was deleted.

application/src/main/java/org/cardanofoundation/ledgersync/repository/AddressTokenRepository.java

Lines changed: 0 additions & 19 deletions
This file was deleted.

application/src/main/java/org/cardanofoundation/ledgersync/repository/AddressTxBalanceRepository.java

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
package org.cardanofoundation.ledgersync.repository;
22

33
import org.cardanofoundation.ledgersync.consumercommon.entity.MultiAsset;
4-
import org.cardanofoundation.ledgersync.consumercommon.entity.Tx;
5-
import org.cardanofoundation.ledgersync.projection.MultiAssetTotalVolumeProjection;
6-
import org.cardanofoundation.ledgersync.projection.MultiAssetTxCountProjection;
74
import org.springframework.data.jpa.repository.JpaRepository;
8-
import org.springframework.data.jpa.repository.Query;
9-
import org.springframework.data.repository.query.Param;
105
import org.springframework.stereotype.Repository;
116
import org.springframework.transaction.annotation.Transactional;
127

@@ -24,19 +19,4 @@ public interface MultiAssetRepository extends JpaRepository<MultiAsset, Long> {
2419
*/
2520
@Transactional(readOnly = true)
2621
List<MultiAsset> findMultiAssetsByFingerprintIn(Collection<String> fingerprints);
27-
28-
@Query("SELECT at.multiAsset.id AS identId, "
29-
+ "COUNT(DISTINCT at.tx) as txCount "
30-
+ "FROM AddressToken at "
31-
+ "WHERE at.tx IN (:txs) "
32-
+ "GROUP BY at.multiAsset")
33-
List<MultiAssetTxCountProjection> getMultiAssetTxCountByTxs(@Param("txs") Collection<Tx> txs);
34-
35-
@Query("SELECT at.multiAsset.id as identId,"
36-
+ "SUM(at.balance) as totalVolume "
37-
+ "FROM AddressToken at "
38-
+ "WHERE at.tx IN (:txs) AND at.balance > 0"
39-
+ "GROUP BY at.multiAsset")
40-
List<MultiAssetTotalVolumeProjection> getMultiAssetTotalVolumeByTxs(
41-
@Param("txs") Collection<Tx> txs);
4222
}
Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
package org.cardanofoundation.ledgersync.service;
2-
3-
import org.cardanofoundation.ledgersync.consumercommon.entity.StakeAddress;
4-
import org.cardanofoundation.ledgersync.consumercommon.entity.Tx;
5-
import org.cardanofoundation.ledgersync.aggregate.AggregatedAddressBalance;
6-
7-
import java.util.Collection;
8-
import java.util.Map;
9-
10-
public interface AddressBalanceService {
11-
12-
/**
13-
* Handle all addresses' balances
14-
*
15-
* @param aggregatedAddressBalanceMap a map with key is address string (Base58 or Bech32 form) and
16-
* value is its aggregated balance
17-
* @param stakeAddressMap a map with key is raw stake address hex and value is the
18-
* respective stake address entity
19-
* @param txMap a map with key is tx hash and value is the respective tx
20-
* entity
21-
*/
22-
void handleAddressBalance(
23-
Map<String, AggregatedAddressBalance> aggregatedAddressBalanceMap,
24-
Map<String, StakeAddress> stakeAddressMap, Map<String, Tx> txMap);
25-
26-
/**
27-
* Rollback address balances stats
28-
*
29-
* @param txs txs being rolled back
30-
*/
31-
void rollbackAddressBalances(Collection<Tx> txs);
32-
}
1+
//package org.cardanofoundation.ledgersync.service;
2+
//
3+
//import org.cardanofoundation.ledgersync.consumercommon.entity.StakeAddress;
4+
//import org.cardanofoundation.ledgersync.consumercommon.entity.Tx;
5+
//import org.cardanofoundation.ledgersync.aggregate.AggregatedAddressBalance;
6+
//
7+
//import java.util.Collection;
8+
//import java.util.Map;
9+
//
10+
//public interface AddressBalanceService {
11+
//
12+
// /**
13+
// * Handle all addresses' balances
14+
// *
15+
// * @param aggregatedAddressBalanceMap a map with key is address string (Base58 or Bech32 form) and
16+
// * value is its aggregated balance
17+
// * @param stakeAddressMap a map with key is raw stake address hex and value is the
18+
// * respective stake address entity
19+
// * @param txMap a map with key is tx hash and value is the respective tx
20+
// * entity
21+
// */
22+
// void handleAddressBalance(
23+
// Map<String, AggregatedAddressBalance> aggregatedAddressBalanceMap,
24+
// Map<String, StakeAddress> stakeAddressMap, Map<String, Tx> txMap);
25+
//
26+
// /**
27+
// * Rollback address balances stats
28+
// *
29+
// * @param txs txs being rolled back
30+
// */
31+
// void rollbackAddressBalances(Collection<Tx> txs);
32+
//}
Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
11
package org.cardanofoundation.ledgersync.service;
22

33

4-
import com.bloxbean.cardano.client.api.util.AssetUtil;
5-
import com.bloxbean.cardano.yaci.core.util.HexUtil;
64
import lombok.RequiredArgsConstructor;
7-
import org.cardanofoundation.ledgersync.aggregate.AggregatedAddress;
8-
import org.cardanofoundation.ledgersync.aggregate.AggregatedAddressBalance;
95
import org.cardanofoundation.ledgersync.aggregate.AggregatedBlock;
10-
import org.cardanofoundation.ledgersync.aggregate.AggregatedTxOut;
11-
import org.cardanofoundation.ledgersync.util.LedgerSyncAssetUtil;
12-
13-
import java.math.BigInteger;
14-
import java.util.List;
15-
16-
import static com.bloxbean.cardano.yaci.core.util.Constants.LOVELACE;
176

187
@RequiredArgsConstructor
198
public abstract class BlockAggregatorService<T> // NOSONAR
@@ -31,48 +20,4 @@ public abstract class BlockAggregatorService<T> // NOSONAR
3120
*/
3221
public abstract AggregatedBlock aggregateBlock(T block);
3322

34-
/**
35-
* This method iterates between all aggregated tx out and map it to
36-
* aggregated address balance data
37-
*
38-
* @param aggregatedTxOuts all aggregated tx outs within a tx
39-
* @param txHash tx hash of tx where the aggregated tx outs associate with
40-
*/
41-
public void mapAggregatedTxOutsToAddressBalanceMap(
42-
List<AggregatedTxOut> aggregatedTxOuts, String txHash) {
43-
// Iterate between all aggregated tx out
44-
aggregatedTxOuts.forEach(aggregatedTxOut -> {
45-
// Get aggregated block address
46-
AggregatedAddress aggregatedAddress = aggregatedTxOut.getAddress();
47-
48-
// Get address string (Base58 or Bech32) from aggregated address
49-
String address = aggregatedAddress.getAddress();
50-
51-
// Get address's native amount
52-
BigInteger nativeAmount = aggregatedTxOut.getNativeAmount();
53-
54-
// Get aggregated address balance data
55-
AggregatedAddressBalance aggregatedAddressBalance =
56-
blockDataService.getAggregatedAddressBalanceFromAddress(address);
57-
58-
/*
59-
* Because the native amount in process is output, it is added to
60-
* existing balance record
61-
*/
62-
aggregatedAddressBalance.addNativeBalance(txHash, nativeAmount);
63-
64-
// Add multi-asset balances
65-
aggregatedTxOut.getAmounts().stream()
66-
.filter(amount -> !LOVELACE.equals(amount.getAssetName()))
67-
.forEach(amount -> {
68-
//byte[] assetName = amount.getAssetName();
69-
String assetName = amount.getAssetName();
70-
String policyId = amount.getPolicyId();
71-
String assetNameAsHex = HexUtil.encodeHexString(amount.getAssetNameBytes(), true);
72-
String fingerprint = AssetUtil.calculateFingerPrint(policyId, assetNameAsHex);
73-
BigInteger quantity = amount.getQuantity();
74-
aggregatedAddressBalance.addAssetBalance(txHash, fingerprint, quantity);
75-
});
76-
});
77-
}
7823
}

0 commit comments

Comments
 (0)