waku-org / waku-rust-bindings

Rust wrapper over go-waku ffi
14 stars 6 forks source link

add discoveryV5 functions #32

Closed richard-ramos closed 1 year ago

richard-ramos commented 1 year ago

Adds the following new items to go-waku c-bindings:

New config items:

New functions

extern char* waku_discv5_start()

Starts the DiscoveryV5 service to discover and connect to new peers

Returns

A JsonResponse. If the execution is successful, the result field is set to true.

For example:

{
  "result": true
}

extern char* waku_discv5_stop()

Stops the DiscoveryV5 service

Returns

A JsonResponse. If the execution is successful, the result field is set to true.

For example:

{
  "result": true
}

See: https://github.com/waku-org/go-waku/pull/400

bacv commented 1 year ago

Slight inconsistency in the waku api was discovered when using discv5:

Leaving this here as we might want to add some notes regarding this functionality or make changes to the api.

danielSanchezQ commented 1 year ago

Slight inconsistency in the waku api was discovered when using discv5:

  • When a node is initialised with discv5 enabled, it just "mounts" the discv5 and discv5 needs to be started separately with node.discv5_start().
  • When node.stop() is called, it stops discv5 internally.
  • If node.discv5_stop() is called before node.stop() then a subsequent node.stop() makes go-waku panic, but waku-bindings keeps waiting for a function to return.

Leaving this here as we might want to add some notes regarding this functionality or make changes to the api.

@richard-ramos are you aware of this? ^^^^

I think either we make it automatic, so when enabling discv5 the service is auto started/stoped. Or it need to be started/stoped manually be the caller.

richard-ramos commented 1 year ago

I did not know. I can work on a fix - would you prefer discv5 is automatically started/stopped? should simplify the API for sure.

danielSanchezQ commented 1 year ago

@richard-ramos yeah, I would say that is better that if enabled, then the service is started and stopped automatically and that's all.