From 6d70a2c3940787f15bfb51267aec0eca34ccea51 Mon Sep 17 00:00:00 2001 From: bxq2011hust Date: Fri, 5 Jan 2024 11:11:48 +0800 Subject: [PATCH] add SendRPCRequest to go binding --- bindings/go/csdk/csdk_wrapper.go | 15 +++++++++++++++ go.mod | 5 +++++ 2 files changed, 20 insertions(+) create mode 100644 go.mod diff --git a/bindings/go/csdk/csdk_wrapper.go b/bindings/go/csdk/csdk_wrapper.go index 3c6488430..824305209 100644 --- a/bindings/go/csdk/csdk_wrapper.go +++ b/bindings/go/csdk/csdk_wrapper.go @@ -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) diff --git a/go.mod b/go.mod new file mode 100644 index 000000000..bb83cf102 --- /dev/null +++ b/go.mod @@ -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