Skip to content

Commit

Permalink
add SendRPCRequest to go binding
Browse files Browse the repository at this point in the history
  • Loading branch information
bxq2011hust committed Jan 5, 2024
1 parent c0cfb1d commit 6d70a2c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
15 changes: 15 additions & 0 deletions bindings/go/csdk/csdk_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,21 @@ func (csdk *CSDK) GetSystemConfigByKey(chanData *CallbackChan, key string) {
C.bcos_rpc_get_system_config_by_key(csdk.sdk, csdk.groupID, nil, cKey, C.bcos_sdk_c_struct_response_cb(C.on_recv_resp_callback), setContext(chanData))
}

// SendRPCRequest to specific group or node, group and node can be empty
func (csdk *CSDK) SendRPCRequest(group, node, request string, chanData *CallbackChan) error {
cGroup := C.CString(group)
defer C.free(unsafe.Pointer(cGroup))
cNode := C.CString(node)
defer C.free(unsafe.Pointer(cNode))
cRequest := C.CString(request)
defer C.free(unsafe.Pointer(cRequest))
C.bcos_rpc_generic_method_call_to_group_node(csdk.sdk, cGroup, cNode, cRequest, C.bcos_sdk_c_struct_response_cb(C.on_recv_resp_callback), setContext(chanData))
if C.bcos_sdk_is_last_opr_success() == 0 {
return fmt.Errorf("bcos_sdk_create_signed_transaction, error: %s", C.GoString(C.bcos_sdk_get_last_error_msg()))
}
return nil
}

// // amop
// func (csdk *CSDK) SubscribeAmopTopicDefaultHandler(topic []string) {
// cTopic := C.CString(topic)
Expand Down
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/FISCO-BCOS/bcos-c-sdk

go 1.21.5

require github.com/patrickmn/go-cache v2.1.0+incompatible

0 comments on commit 6d70a2c

Please sign in to comment.