Skip to content

Commit

Permalink
fix: #19 Init genesis epoch param data whenever app starts
Browse files Browse the repository at this point in the history
  • Loading branch information
Sotatek-HuyLe3 committed Oct 3, 2023
1 parent 341563b commit 9743ee5
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.bloxbean.cardano.client.crypto.Blake2bUtil;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.annotation.PostConstruct;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
Expand All @@ -26,6 +27,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;

import java.math.BigDecimal;
import java.math.BigInteger;
Expand Down Expand Up @@ -93,6 +95,7 @@ public class GenesisDataServiceImpl implements GenesisDataService {
String genesisConway; // conway have no data to handle

String genesisHash;
GenesisData genesisData;
final ObjectMapper objectMapper;
final BlockRepository blockRepository;
final SlotLeaderRepository slotLeaderRepository;
Expand All @@ -104,10 +107,9 @@ public class GenesisDataServiceImpl implements GenesisDataService {
final EpochParamService epochParamService;
final GenesisFetching genesisFetching;

@Transactional
public void setupData(String genesisHash) {
this.genesisHash = genesisHash;
GenesisData genesisData = GenesisData.builder()
@PostConstruct
void init(){
genesisData = GenesisData.builder()
.txs(new ArrayList<>())
.txOuts(new ArrayList<>())
.build();
Expand All @@ -124,6 +126,11 @@ public void setupData(String genesisHash) {
epochParamService.setDefBabbageEpochParam(genesisData.getBabbage());
log.info("setup genesis cost model");
costModelService.setGenesisCostModel(genesisData.getCostModel());
}

@Transactional
public void setupData(String genesisHash) {
this.genesisHash = genesisHash;
// if block table have blocks do not thing
if (blockRepository.getBlockIdHeight().isPresent()) {
return;
Expand Down

0 comments on commit 9743ee5

Please sign in to comment.