Skip to content

Commit 0fbea6b

Browse files
refactor: create the data directory if it doesn't exist in kyoto example
1 parent 4f4105a commit 0fbea6b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

examples/src/main/kotlin/Kyoto.kt

Lines changed: 5 additions & 5 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)

0 commit comments

Comments
 (0)