@@ -40,12 +40,12 @@ extern NewNodeResult NewNode(NodeInitOptions cOptions);
4040extern Result NodeClose(uintptr_t nodePtr);
4141extern Result P2PInfo(uintptr_t nodePtr);
4242extern Result P2PgetAllReplicators(uintptr_t nodePtr);
43- extern Result P2PsetReplicator(uintptr_t nodePtr, char* collections, char* peerInfo );
44- extern Result P2PdeleteReplicator(uintptr_t nodePtr, char* collections, char* peerInfo );
43+ extern Result P2PsetReplicator(uintptr_t nodePtr, char* collections, char* addresses );
44+ extern Result P2PdeleteReplicator(uintptr_t nodePtr, char* collections, char* id );
4545extern Result P2PcollectionAdd(uintptr_t nodePtr, char* collections);
4646extern Result P2PcollectionRemove(uintptr_t nodePtr, char* collections);
4747extern Result P2PcollectionGetAll(uintptr_t nodePtr);
48- extern Result P2Pconnect(uintptr_t nodePtr, char* peerID, char* peerAddresses);
48+ extern Result P2Pconnect(uintptr_t nodePtr, char* peerAddresses);
4949extern Result P2PdocumentAdd(uintptr_t nodePtr, char* collections);
5050extern Result P2PdocumentRemove(uintptr_t nodePtr, char* collections);
5151extern Result P2PdocumentGetAll(uintptr_t nodePtr);
@@ -104,41 +104,41 @@ func NewCWrapper(node *node.Node) (*CWrapper, error) {
104104 }, nil
105105}
106106
107- func (w * CWrapper ) PeerInfo () client. PeerInfo {
107+ func (w * CWrapper ) PeerInfo () ([] string , error ) {
108108 res := ConvertAndFreeCResult (C .P2PInfo (C .uintptr_t (w .handle )))
109109
110110 if res .Status != 0 {
111- return client. PeerInfo {}
111+ return nil , errors . New ( res . Error )
112112 }
113113
114- addrInfo , err := unmarshalResult [client. PeerInfo ](res .Value )
114+ addresses , err := unmarshalResult [[] string ](res .Value )
115115 if err != nil {
116- return client. PeerInfo {}
116+ return nil , err
117117 }
118- return addrInfo
118+ return addresses , nil
119119}
120120
121- func (w * CWrapper ) SetReplicator (ctx context.Context , info client. PeerInfo , collections ... string ) error {
122- peerStr := C .CString (info . String ( ))
121+ func (w * CWrapper ) SetReplicator (ctx context.Context , addresses [] string , collections ... string ) error {
122+ addrStr := C .CString (strings . Join ( addresses , "," ))
123123 colStr := C .CString (strings .Join (collections , "," ))
124- defer C .free (unsafe .Pointer (peerStr ))
124+ defer C .free (unsafe .Pointer (addrStr ))
125125 defer C .free (unsafe .Pointer (colStr ))
126126
127- res := ConvertAndFreeCResult (C .P2PsetReplicator (C .uintptr_t (w .handle ), colStr , peerStr ))
127+ res := ConvertAndFreeCResult (C .P2PsetReplicator (C .uintptr_t (w .handle ), colStr , addrStr ))
128128
129129 if res .Status != 0 {
130130 return errors .New (res .Error )
131131 }
132132 return nil
133133}
134134
135- func (w * CWrapper ) DeleteReplicator (ctx context.Context , info client. PeerInfo , collections ... string ) error {
136- peerStr := C .CString (info . String () )
135+ func (w * CWrapper ) DeleteReplicator (ctx context.Context , id string , collections ... string ) error {
136+ peerID := C .CString (id )
137137 colStr := C .CString (strings .Join (collections , "," ))
138- defer C .free (unsafe .Pointer (peerStr ))
138+ defer C .free (unsafe .Pointer (peerID ))
139139 defer C .free (unsafe .Pointer (colStr ))
140140
141- res := ConvertAndFreeCResult (C .P2PdeleteReplicator (C .uintptr_t (w .handle ), colStr , peerStr ))
141+ res := ConvertAndFreeCResult (C .P2PdeleteReplicator (C .uintptr_t (w .handle ), colStr , peerID ))
142142
143143 if res .Status != 0 {
144144 return errors .New (res .Error )
@@ -822,13 +822,11 @@ func (w *CWrapper) PrintDump(ctx context.Context) error {
822822 panic ("not implemented" )
823823}
824824
825- func (w * CWrapper ) Connect (ctx context.Context , addr client.PeerInfo ) error {
826- cPeerID := C .CString (addr .ID )
827- cPeerAddresses := C .CString (strings .Join (addr .Addresses , "," ))
828- defer C .free (unsafe .Pointer (cPeerID ))
825+ func (w * CWrapper ) Connect (ctx context.Context , addresses []string ) error {
826+ cPeerAddresses := C .CString (strings .Join (addresses , "," ))
829827 defer C .free (unsafe .Pointer (cPeerAddresses ))
830828 callHandle := getNodeOrTxnHandle (w .handle , ctx )
831- res := ConvertAndFreeCResult (C .P2Pconnect (callHandle , cPeerID , cPeerAddresses ))
829+ res := ConvertAndFreeCResult (C .P2Pconnect (callHandle , cPeerAddresses ))
832830 if res .Status != 0 {
833831 return errors .New (res .Error )
834832 }
0 commit comments