-
Notifications
You must be signed in to change notification settings - Fork 3
fix: delete vss network graph using new ffi client #775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
676c263
fix: delete vss network graph using new ffi client
ovitrif 088b327
Merge branch 'master' into fix/stale-graph
ovitrif f6343bb
chore: lint and cleanup
ovitrif de50b85
chore: update `/pr` to use `.ai/pr` context
ovitrif a61e9f1
Merge branch 'master' into fix/stale-graph-reset
ovitrif 13788bd
Merge remote-tracking branch 'origin/fix/node-stopping-bg-payments' i…
ovitrif f120581
chore: update vss-rust-client-ffi
ovitrif b1693c0
chore: lint
ovitrif e556b04
chore: update vss-rust-client-ffi
ovitrif ffffc4f
fix: reset graph if channel counterparty missing
ovitrif c2fe613
feat: integrate vss-client-ffi 0.5.12 ldk api
ovitrif 089b36d
Merge branch 'fix/node-stopping-bg-payments' into fix/stale-graph-reset
ovitrif 0c87e36
Merge branch 'master' into fix/stale-graph-reset
ovitrif 489a61e
Merge branch 'master' into fix/stale-graph-reset
ovitrif 6e2fef8
chore: merge
ovitrif File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
app/src/main/java/to/bitkit/data/backup/VssBackupClientLdk.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| package to.bitkit.data.backup | ||
|
|
||
| import com.synonym.vssclient.KeyVersion | ||
| import com.synonym.vssclient.LdkNamespace | ||
| import com.synonym.vssclient.VssItem | ||
| import com.synonym.vssclient.vssDeleteLdk | ||
| import com.synonym.vssclient.vssGetLdk | ||
| import com.synonym.vssclient.vssListKeysLdk | ||
| import com.synonym.vssclient.vssListLdk | ||
| import com.synonym.vssclient.vssStoreLdk | ||
| import dagger.assisted.Assisted | ||
| import dagger.assisted.AssistedFactory | ||
| import dagger.assisted.AssistedInject | ||
| import kotlinx.coroutines.CoroutineDispatcher | ||
| import kotlinx.coroutines.withContext | ||
| import to.bitkit.di.IoDispatcher | ||
| import to.bitkit.utils.Logger | ||
|
|
||
| class VssBackupClientLdk @AssistedInject constructor( | ||
| @IoDispatcher private val ioDispatcher: CoroutineDispatcher, | ||
| @Assisted private val awaitSetup: suspend () -> Unit, | ||
|
jvsena42 marked this conversation as resolved.
Outdated
|
||
| ) { | ||
| companion object { | ||
| private const val TAG = "VssBackupClientLdk" | ||
| } | ||
|
|
||
| @AssistedFactory | ||
| interface Factory { | ||
| fun create(awaitSetup: suspend () -> Unit): VssBackupClientLdk | ||
|
jvsena42 marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| suspend fun getObject( | ||
| key: String, | ||
| namespace: LdkNamespace = LdkNamespace.Default, | ||
| ): Result<VssItem?> = withContext(ioDispatcher) { | ||
| awaitSetup() | ||
| Logger.verbose("VSS LDK 'getObject' call for '$key'", context = TAG) | ||
| runCatching { | ||
| vssGetLdk(key = key, namespace = namespace) | ||
| }.onSuccess { | ||
| if (it == null) { | ||
| Logger.verbose("VSS LDK 'getObject' success null for '$key'", context = TAG) | ||
| } else { | ||
| Logger.verbose("VSS LDK 'getObject' success for '$key'", context = TAG) | ||
| } | ||
| }.onFailure { | ||
| Logger.verbose("VSS LDK 'getObject' error for '$key'", it, context = TAG) | ||
| } | ||
| } | ||
|
|
||
| suspend fun putObject( | ||
| key: String, | ||
| data: ByteArray, | ||
| namespace: LdkNamespace = LdkNamespace.Default, | ||
| ): Result<VssItem> = withContext(ioDispatcher) { | ||
| awaitSetup() | ||
| Logger.verbose("VSS LDK 'putObject' call for '$key'", context = TAG) | ||
| runCatching { | ||
| vssStoreLdk(key = key, value = data, namespace = namespace) | ||
| }.onSuccess { | ||
| Logger.verbose("VSS LDK 'putObject' success for '$key' at version: '${it.version}'", context = TAG) | ||
| }.onFailure { | ||
| Logger.verbose("VSS LDK 'putObject' error for '$key'", it, context = TAG) | ||
| } | ||
| } | ||
|
|
||
| suspend fun deleteObject( | ||
| key: String, | ||
| namespace: LdkNamespace = LdkNamespace.Default, | ||
| ): Result<Boolean> = withContext(ioDispatcher) { | ||
| awaitSetup() | ||
| Logger.verbose("VSS LDK 'deleteObject' call for '$key'", context = TAG) | ||
| runCatching { | ||
| vssDeleteLdk(key = key, namespace = namespace) | ||
| }.onSuccess { wasDeleted -> | ||
| if (wasDeleted) { | ||
| Logger.verbose("VSS LDK 'deleteObject' success for '$key' - key was deleted", context = TAG) | ||
| } else { | ||
| Logger.verbose("VSS LDK 'deleteObject' success for '$key' - key did not exist", context = TAG) | ||
| } | ||
| }.onFailure { | ||
| Logger.verbose("VSS LDK 'deleteObject' error for '$key'", it, context = TAG) | ||
| } | ||
| } | ||
|
|
||
| suspend fun listKeys( | ||
| namespace: LdkNamespace = LdkNamespace.Default, | ||
| ): Result<List<KeyVersion>> = withContext(ioDispatcher) { | ||
| awaitSetup() | ||
| Logger.verbose("VSS LDK 'listKeys' call", context = TAG) | ||
| runCatching { | ||
| vssListKeysLdk(namespace = namespace) | ||
| }.onSuccess { | ||
| Logger.verbose("VSS LDK 'listKeys' success - found ${it.size} key(s)", context = TAG) | ||
| }.onFailure { | ||
| Logger.verbose("VSS LDK 'listKeys' error", it, context = TAG) | ||
| } | ||
| } | ||
|
|
||
| suspend fun listItems( | ||
| namespace: LdkNamespace = LdkNamespace.Default, | ||
| ): Result<List<VssItem>> = withContext(ioDispatcher) { | ||
| awaitSetup() | ||
| Logger.verbose("VSS LDK 'listItems' call", context = TAG) | ||
| runCatching { | ||
| vssListLdk(namespace = namespace) | ||
| }.onSuccess { | ||
| Logger.verbose("VSS LDK 'listItems' success - found ${it.size} item(s)", context = TAG) | ||
| }.onFailure { | ||
| Logger.verbose("VSS LDK 'listItems' error", it, context = TAG) | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.