Some documentation comments update on the nimbus wrapper
This commit is contained in:
parent
11a24885a5
commit
e841c08b23
|
@ -47,10 +47,15 @@ typedef struct {
|
||||||
|
|
||||||
typedef void (*received_msg_handler)(received_message* msg, void* udata);
|
typedef void (*received_msg_handler)(received_message* msg, void* udata);
|
||||||
|
|
||||||
/** Initialize Nim and the status library */
|
/** Initialize Nim and the Status library. Must be called before anything else
|
||||||
|
* of the API. Also, all following calls must come from the same thread as from
|
||||||
|
* which this call was done.
|
||||||
|
*/
|
||||||
void NimMain();
|
void NimMain();
|
||||||
|
|
||||||
/** Start nimbus event loop, connect to bootnodes etc */
|
/** Start Ethereum node with Whisper capability, start discovery and
|
||||||
|
* connect to Status fleet.
|
||||||
|
*/
|
||||||
void nimbus_start(uint16_t port);
|
void nimbus_start(uint16_t port);
|
||||||
|
|
||||||
/** Add peers to connect to - must be called after nimbus_start */
|
/** Add peers to connect to - must be called after nimbus_start */
|
||||||
|
@ -62,41 +67,52 @@ void nimbus_add_peer(const char* nodeId);
|
||||||
*/
|
*/
|
||||||
void nimbus_poll();
|
void nimbus_poll();
|
||||||
|
|
||||||
void nimbus_post_public(const char* channel, const char* payload);
|
/** Asymmetric Keys API */
|
||||||
void nimbus_join_public_chat(const char* channel, received_msg_handler msg);
|
|
||||||
|
|
||||||
/* Whisper API */
|
|
||||||
|
|
||||||
/* Helper, can be removed */
|
|
||||||
topic nimbus_string_to_topic(const char* s);
|
|
||||||
|
|
||||||
/* Asymmetric Keys API */
|
|
||||||
|
|
||||||
|
/** It is important that caller makes a copy of the returned strings before
|
||||||
|
* doing any other API calls. */
|
||||||
const char* nimbus_new_keypair();
|
const char* nimbus_new_keypair();
|
||||||
const char* nimbus_add_keypair(const uint8_t* privkey);
|
const char* nimbus_add_keypair(const uint8_t* privkey);
|
||||||
int nimbus_delete_keypair(const char* id);
|
int nimbus_delete_keypair(const char* id);
|
||||||
int nimbus_get_private_key(const char* id, uint8_t* privkey);
|
int nimbus_get_private_key(const char* id, uint8_t* privkey);
|
||||||
|
|
||||||
/* Symmetric Keys API */
|
/** Symmetric Keys API */
|
||||||
|
|
||||||
|
/** It is important that caller makes a copy of the returned strings before
|
||||||
|
* doing any other API calls. */
|
||||||
const char* nimbus_add_symkey(const uint8_t* symkey);
|
const char* nimbus_add_symkey(const uint8_t* symkey);
|
||||||
const char* nimbus_add_symkey_from_password(const char* password);
|
const char* nimbus_add_symkey_from_password(const char* password);
|
||||||
int nimbus_delete_symkey(const char* id);
|
int nimbus_delete_symkey(const char* id);
|
||||||
int nimbus_get_symkey(const char* id, uint8_t* symkey);
|
int nimbus_get_symkey(const char* id, uint8_t* symkey);
|
||||||
|
|
||||||
/* Whisper message posting and receiving API */
|
/** Whisper message posting and receiving API */
|
||||||
|
|
||||||
/* Subscribe to given filter */
|
/** Subscribe to given filter. The void pointer udata will be passed to the
|
||||||
|
* received_msg_handler callback.
|
||||||
|
*/
|
||||||
const char* nimbus_subscribe_filter(filter_options* filter_options,
|
const char* nimbus_subscribe_filter(filter_options* filter_options,
|
||||||
received_msg_handler msg, void* udata);
|
received_msg_handler msg, void* udata);
|
||||||
int nimbus_unsubscribe_filter(const char* id);
|
int nimbus_unsubscribe_filter(const char* id);
|
||||||
/* Post Whisper message */
|
/* Post Whisper message to the queue */
|
||||||
int nimbus_post(post_message* msg);
|
int nimbus_post(post_message* msg);
|
||||||
|
|
||||||
// TODO: why are these getters needed?
|
/** TODO: why are following two getters needed? */
|
||||||
|
|
||||||
|
/** Get the minimum required PoW of this node */
|
||||||
double nimbus_get_min_pow();
|
double nimbus_get_min_pow();
|
||||||
|
|
||||||
|
/** Get the currently set bloom filter of this node. This will automatically
|
||||||
|
*update for each filter subsribed to.
|
||||||
|
*/
|
||||||
void nimbus_get_bloom_filter(uint8_t* bloomfilter);
|
void nimbus_get_bloom_filter(uint8_t* bloomfilter);
|
||||||
|
|
||||||
|
/** Example helper, can be removed */
|
||||||
|
topic nimbus_string_to_topic(const char* s);
|
||||||
|
|
||||||
|
/** Very limited Status chat API */
|
||||||
|
void nimbus_post_public(const char* channel, const char* payload);
|
||||||
|
void nimbus_join_public_chat(const char* channel, received_msg_handler msg);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -204,14 +204,14 @@ proc nimbus_string_to_topic(s: cstring): CTopic {.exportc.} =
|
||||||
|
|
||||||
proc nimbus_new_keypair(): cstring {.exportc.} =
|
proc nimbus_new_keypair(): cstring {.exportc.} =
|
||||||
## It is important that the caller makes a copy of the returned cstring before
|
## It is important that the caller makes a copy of the returned cstring before
|
||||||
## doing any other API calls.
|
## doing any other API calls. This might not hold for all types of GC.
|
||||||
result = generateRandomID()
|
result = generateRandomID()
|
||||||
whisperKeys.asymKeys.add($result, newKeyPair())
|
whisperKeys.asymKeys.add($result, newKeyPair())
|
||||||
|
|
||||||
proc nimbus_add_keypair(key: ptr PrivateKey):
|
proc nimbus_add_keypair(key: ptr PrivateKey):
|
||||||
cstring {.exportc.} =
|
cstring {.exportc.} =
|
||||||
## It is important that the caller makes a copy of the returned cstring before
|
## It is important that the caller makes a copy of the returned cstring before
|
||||||
## doing any other API calls.
|
## doing any other API calls. This might not hold for all types of GC.
|
||||||
result = generateRandomID()
|
result = generateRandomID()
|
||||||
|
|
||||||
# Creating a KeyPair here does a copy of the key and so does the add
|
# Creating a KeyPair here does a copy of the key and so does the add
|
||||||
|
@ -234,7 +234,7 @@ proc nimbus_get_private_key(id: cstring, privateKey: ptr PrivateKey):
|
||||||
|
|
||||||
proc nimbus_add_symkey(key: ptr SymKey): cstring {.exportc.} =
|
proc nimbus_add_symkey(key: ptr SymKey): cstring {.exportc.} =
|
||||||
## It is important that the caller makes a copy of the returned cstring before
|
## It is important that the caller makes a copy of the returned cstring before
|
||||||
## doing any other API calls.
|
## doing any other API calls. This might not hold for all types of GC.
|
||||||
result = generateRandomID().cstring
|
result = generateRandomID().cstring
|
||||||
|
|
||||||
# Copy of key happens at add
|
# Copy of key happens at add
|
||||||
|
@ -243,7 +243,7 @@ proc nimbus_add_symkey(key: ptr SymKey): cstring {.exportc.} =
|
||||||
proc nimbus_add_symkey_from_password(password: cstring):
|
proc nimbus_add_symkey_from_password(password: cstring):
|
||||||
cstring {.exportc.} =
|
cstring {.exportc.} =
|
||||||
## It is important that the caller makes a copy of the returned cstring before
|
## It is important that the caller makes a copy of the returned cstring before
|
||||||
## doing any other API calls.
|
## doing any other API calls. This might not hold for all types of GC.
|
||||||
var ctx: HMAC[sha256]
|
var ctx: HMAC[sha256]
|
||||||
var symKey: SymKey
|
var symKey: SymKey
|
||||||
if pbkdf2(ctx, $password, "", 65356, symKey) != sizeof(SymKey):
|
if pbkdf2(ctx, $password, "", 65356, symKey) != sizeof(SymKey):
|
||||||
|
|
Loading…
Reference in New Issue