@@ -11,49 +11,17 @@ import (
1111
1212// ValidationInterfaceCallbacks contains all the Go callback function types for validation interface.
1313type ValidationInterfaceCallbacks struct {
14- OnBlockChecked func (block * BlockPointer , state * BlockValidationState )
14+ OnBlockChecked func (block * Block , state * BlockValidationState )
1515}
1616
1717//export go_validation_interface_block_checked_bridge
18- func go_validation_interface_block_checked_bridge (user_data unsafe.Pointer , block * C.btck_BlockPointer , state * C.btck_BlockValidationState ) {
18+ func go_validation_interface_block_checked_bridge (user_data unsafe.Pointer , block * C.btck_Block , state * C.btck_BlockValidationState ) {
1919 // Convert void* back to Handle - user_data contains Handle ID
2020 handle := cgo .Handle (user_data )
2121 // Retrieve original Go callback struct
2222 callbacks := handle .Value ().(* ValidationInterfaceCallbacks )
2323
2424 if callbacks .OnBlockChecked != nil {
25- goBlock := & BlockPointer {ptr : (* C .btck_BlockPointer )(unsafe .Pointer (block ))}
26- goState := & BlockValidationState {ptr : (* C .btck_BlockValidationState )(unsafe .Pointer (state ))}
27- callbacks .OnBlockChecked (goBlock , goState )
25+ callbacks .OnBlockChecked (newBlockFromPtr (block ), & BlockValidationState {ptr : state })
2826 }
2927}
30-
31- // BlockPointer wraps the C kernel_BlockPointer for validation interface callbacks
32- type BlockPointer struct {
33- ptr * C.btck_BlockPointer
34- }
35-
36- // GetHash returns the block hash
37- func (bp * BlockPointer ) GetHash () (* BlockHash , error ) {
38- if bp .ptr == nil {
39- return nil , ErrBlockUninitialized
40- }
41-
42- hashPtr := C .btck_block_pointer_get_hash (bp .ptr )
43- if hashPtr == nil {
44- return nil , ErrKernelBlockGetHash
45- }
46-
47- return & BlockHash {ptr : hashPtr }, nil
48- }
49-
50- // Bytes returns the serialized block
51- func (bp * BlockPointer ) Bytes () ([]byte , error ) {
52- if bp .ptr == nil {
53- return nil , ErrBlockUninitialized
54- }
55-
56- return writeToBytes (func (writer C.btck_WriteBytes , user_data unsafe.Pointer ) C.int {
57- return C .btck_block_pointer_to_bytes (bp .ptr , writer , user_data )
58- })
59- }
0 commit comments