Skip to content

Commit c9a844a

Browse files
committed
Make block tip notification safe
1 parent e932b52 commit c9a844a

File tree

1 file changed

+7
-3
lines changed
  • libbitcoinkernel-sys/src

1 file changed

+7
-3
lines changed

libbitcoinkernel-sys/src/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ impl From<ChainType> for kernel_ChainType {
171171
}
172172
}
173173

174-
pub trait KNBlockTipFn: Fn(SynchronizationState, *mut kernel_BlockIndex) {}
175-
impl<F: Fn(SynchronizationState, *mut kernel_BlockIndex)> KNBlockTipFn for F {}
174+
pub trait KNBlockTipFn: Fn(SynchronizationState, BlockHash) {}
175+
impl<F: Fn(SynchronizationState, BlockHash)> KNBlockTipFn for F {}
176176

177177
pub trait KNHeaderTipFn: Fn(SynchronizationState, i64, i64, bool) {}
178178
impl<F: Fn(SynchronizationState, i64, i64, bool)> KNHeaderTipFn for F {}
@@ -209,7 +209,11 @@ unsafe extern "C" fn kn_block_tip_wrapper(
209209
block_index: *mut kernel_BlockIndex,
210210
) {
211211
let holder = &*(user_data as *mut KernelNotificationInterfaceCallbackHolder);
212-
(holder.kn_block_tip)(state.into(), block_index);
212+
let hash = kernel_block_index_get_block_hash(block_index) ;
213+
let res = BlockHash {
214+
hash: (&*hash).hash,
215+
};
216+
(holder.kn_block_tip)(state.into(), res);
213217
}
214218

215219
unsafe extern "C" fn kn_header_tip_wrapper(

0 commit comments

Comments
 (0)