Skip to content

Commit 7ceeeb5

Browse files
refactor: create the data directory if it doesn't exist in kyoto example
1 parent 88eca89 commit 7ceeeb5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

examples/src/main/kotlin/Kyoto.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import java.nio.file.Files
88
import java.nio.file.Paths
99
import org.slf4j.Logger
1010
import org.slf4j.LoggerFactory
11-
12-
11+
import java.nio.file.Path
1312

1413
fun main() {
1514
// Regtest environment must have Compact block filter enabled to run this
@@ -19,9 +18,10 @@ fun main() {
1918
val ip: IpAddress = IpAddress.fromIpv4(127u, 0u, 0u, 1u)
2019
val peer: Peer = Peer(ip, 18444u, false)
2120
val peers: List<Peer> = listOf(peer)
22-
val currentPath = Paths.get("examples/data").toAbsolutePath().normalize()
23-
println("Current path: $currentPath")
24-
val persistenceFilePath = Files.createTempDirectory(currentPath, "kyoto-data_")
21+
22+
val persistenceDir: Path = Paths.get("examples/data").toAbsolutePath().normalize()
23+
Files.createDirectories(persistenceDir)
24+
val persistenceFilePath: Path = Files.createTempDirectory(persistenceDir, "kyoto-data_")
2525

2626
val wallet = getNewWallet(ActiveWalletScriptType.P2WPKH, Network.REGTEST)
2727
val address = wallet.revealNextAddress(KeychainKind.EXTERNAL)
@@ -39,7 +39,7 @@ fun main() {
3939
val lightClient = CbfBuilder()
4040
.peers(peers)
4141
.connections(1u)
42-
.scanType(ScanType.New)
42+
.scanType(ScanType.Sync)
4343
.dataDir(persistenceFilePath.toString())
4444
.build(wallet)
4545
val client = lightClient.client

0 commit comments

Comments
 (0)