RGB KVStore Integration #17
Open
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.
This PR adds database persistence for RGB-specific data via the
KVStoreSynctrait, replacing direct filesystem operations with KVStore calls while maintaining filesystem fallback for backward compatibility.Changes
New KVStore Functions (
rgb_utils/mod.rs)Added namespace constants and persistence functions:
New functions:
read_rgb_transfer_info_kv/write_rgb_transfer_info_kvread_rgb_channel_info_kv/write_rgb_channel_info_kv/remove_rgb_channel_info_kvread_rgb_payment_info_kv/write_rgb_payment_info_kvget_rgb_channel_info_pending_kvDependency Injection
KVStore is now passed through struct fields:
KeysManager.rgb_kv_storeInMemorySigner.rgb_kv_storeOutboundPayments.rgb_kv_storeChannelContext.rgb_kv_storeFilesystem Fallback
All RGB functions support graceful fallback when KVStore is
None:color_htlc- KVStore read/write with filesystem fallbackcolor_closing- Usesget_rgb_channel_info_pendingwith fallbackis_channel_rgb- Checks KVStore first, then filesystemget_rgb_channel_info- KVStore with filesystem fallbackrename_rgb_files- Operates on both for compatibilityDesign
Option<&Arc<dyn KVStoreSync + Send + Sync>>Breaking Changes
The following public functions now require an additional
kv_storeparameter:is_channel_rgbkv_store: Option<&Arc<dyn KVStoreSync + Send + Sync>>update_rgb_channel_amountkv_store: Option<&Arc<dyn KVStoreSync + Send + Sync>>write_rgb_payment_info_filekv_store: &Arc<dyn KVStoreSync + Send + Sync>(also removedldk_data_dir)Callers can pass
Noneto maintain existing filesystem-only behavior.