Skip to content

Commit fbbdcbf

Browse files
committed
Unify function naming in Go
1 parent 672cab0 commit fbbdcbf

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

native/libp2p_nif/libp2p.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ ERL_FUNCTION(host_set_stream_handler)
191191

192192
IF_ERROR(!enif_self(env, pid), "failed to get pid");
193193

194-
SetStreamHandler(host, proto_id, (void *)pid, send_message);
194+
HostSetStreamHandler(host, proto_id, (void *)pid, send_message);
195195

196196
return enif_make_atom(env, "ok");
197197
}
@@ -205,7 +205,7 @@ ERL_FUNCTION(host_new_stream)
205205
IF_ERROR(!enif_inspect_binary(env, argv[2], &bin), "invalid protocol ID");
206206
GoString proto_id = {(const char *)bin.data, bin.size};
207207

208-
uintptr_t result = NewStream(host, id, proto_id);
208+
uintptr_t result = HostNewStream(host, id, proto_id);
209209
return get_handle_result(env, Stream, result);
210210
}
211211

@@ -225,7 +225,7 @@ ERL_FUNCTION(peerstore_add_addrs)
225225
u_long ttl;
226226
IF_ERROR(!enif_get_uint64(env, argv[3], &ttl), "invalid TTL");
227227

228-
AddAddrs(ps, id, addrs, ttl);
228+
PeerstoreAddAddrs(ps, id, addrs, ttl);
229229
return enif_make_atom(env, "ok");
230230
}
231231

native/libp2p_nif/main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ func (h C.uintptr_t) HostClose() {
8080
handle.Value().(host.Host).Close()
8181
}
8282

83-
//export SetStreamHandler
84-
func (h C.uintptr_t) SetStreamHandler(protoId string, procId C.erl_pid_t, callback C.send_message_t) {
83+
//export HostSetStreamHandler
84+
func (h C.uintptr_t) HostSetStreamHandler(protoId string, procId C.erl_pid_t, callback C.send_message_t) {
8585
handle := cgo.Handle(h)
8686
host := handle.Value().(host.Host)
8787
// WARN: we clone the string because the underlying buffer is owned by Elixir
@@ -92,8 +92,8 @@ func (h C.uintptr_t) SetStreamHandler(protoId string, procId C.erl_pid_t, callba
9292
host.SetStreamHandler(protocol.ID(goProtoId), handler)
9393
}
9494

95-
//export NewStream
96-
func (h C.uintptr_t) NewStream(pid C.uintptr_t, protoId string) C.uintptr_t {
95+
//export HostNewStream
96+
func (h C.uintptr_t) HostNewStream(pid C.uintptr_t, protoId string) C.uintptr_t {
9797
host := cgo.Handle(h).Value().(host.Host)
9898
peerId := cgo.Handle(pid).Value().(peer.ID)
9999
// WARN: we clone the string because the underlying buffer is owned by Elixir
@@ -127,8 +127,8 @@ func (h C.uintptr_t) HostAddrs() C.uintptr_t {
127127
/* Peerstore methods */
128128
/*********************/
129129

130-
//export AddAddrs
131-
func (ps C.uintptr_t) AddAddrs(id, addrs C.uintptr_t, ttl uint64) {
130+
//export PeerstoreAddAddrs
131+
func (ps C.uintptr_t) PeerstoreAddAddrs(id, addrs C.uintptr_t, ttl uint64) {
132132
psv := cgo.Handle(ps).Value().(peerstore.Peerstore)
133133
idv := cgo.Handle(id).Value().(peer.ID)
134134
addrsv := cgo.Handle(addrs).Value().([]multiaddr.Multiaddr)

0 commit comments

Comments
 (0)