Commit ace90e02 authored by Schudel, MJ (Michel)'s avatar Schudel, MJ (Michel)

made nice lamba for loading blockchain.

parent 82bb7b23
......@@ -15,7 +15,6 @@ import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.Set;
/**
......@@ -59,15 +58,11 @@ public class BlockchainService {
}
private void initializeBlockchain() {
if (this.blockchain == null) {
Optional<Blockchain> blockchainOptional = genericRepository.load(Blockchain.class);
if (!blockchainOptional.isPresent()) {
this.blockchain = Blockchain.create();
genericRepository.save(this.blockchain);
} else {
this.blockchain = blockchainOptional.get();
}
}
this.blockchain = genericRepository.load(Blockchain.class).orElseGet(() -> {
Blockchain chain = Blockchain.create();
genericRepository.save(chain);
return chain;
});
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment