The criteria to create subscription to a light node in JSON Format:
```ts
{
contentFilters: ContentFilter[];
pubsubTopic: string?;
}
```
Fields:
-`contentFilters`: Array of [`ContentFilter`](#contentfilter-type) being subscribed to / unsubscribed from.
-`topic`: Optional pubsub topic.
### `ContentFilter` type
```ts
{
contentTopic: string;
}
```
Fields:
-`contentTopic`: The content topic of a Waku message.
### `StoreQuery` type
Criteria used to retrieve historical messages
```ts
interface StoreQuery {
pubsubTopic?: string;
contentFilters?: ContentFilter[];
startTime?: number;
endTime?: number;
pagingOptions?: PagingOptions
}
```
Fields:
-`pubsubTopic`: The pubsub topic on which messages are published.
-`contentFilters`: Array of [`ContentFilter`](#contentfilter-type) to query for historical messages,
-`startTime`: The inclusive lower bound on the timestamp of queried messages. This field holds the Unix epoch time in nanoseconds.
-`endTime`: The inclusive upper bound on the timestamp of queried messages. This field holds the Unix epoch time in nanoseconds.
-`pagingOptions`: Paging information in [`PagingOptions`](#pagingoptions-type) format.
### `StoreResponse` type
The response received after doing a query to a store node:
```ts
interface StoreResponse {
messages: JsonMessage[];
pagingOptions?: PagingOptions;
}
```
Fields:
-`messages`: Array of retrieved historical messages in [`JsonMessage`](#jsonmessage-type) format.
-`pagingOption`: Paging information in [`PagingOptions`](#pagingoptions-type) format from which to resume further historical queries
### `PagingOptions` type
```ts
interface PagingOptions {
pageSize: number;
cursor?: Index;
forward: bool;
}
```
Fields:
-`pageSize`: Number of messages to retrieve per page.
-`cursor`: Message Index from which to perform pagination. If not included and forward is set to true, paging will be performed from the beginning of the list. If not included and forward is set to false, paging will be performed from the end of the list.
-`forward`: `true` if paging forward, `false` if paging backward
### `Index` type
```ts
interface Index {
digest: string;
receiverTime: number;
senderTime: number;
pubsubTopic: string;
}
```
Fields:
-`digest`: Hash of the message at this [`Index`](#index-type).
-`receiverTime`: UNIX timestamp in nanoseconds at which the message at this [`Index`](#index-type) was received.
-`senderTime`: UNIX timestamp in nanoseconds at which the message is generated by its sender.
-`pubsubTopic`: The pubsub topic of the message at this [`Index`](#index-type).
## Events
Asynchronous events require a callback to be registered.
An example of an asynchronous event that might be emitted is receiving a message.
When an event is emitted, this callback will be triggered receiving a JSON string of type `JsonSignal`.
### `JsonSignal` type
```ts
{
type: string;
event: any;
}
```
Fields:
-`type`: Type of signal being emitted. Currently, only `message` is available.
Register callback to act as event handler and receive application signals,
which are used to react to asynchronous events in Waku.
**Parameters**
1.`WakuCallBack cb`: callback that will be executed when an async event is emitted.
## Node management
### `JsonConfig` type
Type holding a node configuration:
```ts
interface JsonConfig {
host?: string;
port?: number;
advertiseAddr?: string;
nodeKey?: string;
keepAliveInterval?: number;
relay?: boolean;
relayTopics?: Array\<string\>;
gossipsubParameters?: GossipSubParameters;
minPeersToPublish?: number
legacyFilter?: boolean;
discV5?: boolean;
discV5BootstrapNodes?: Array\<string\>;
discV5UDPPort?: number;
store?: boolean;
databaseURL?: string;
storeRetentionMaxMessages?: number;
storeRetentionTimeSeconds?: number;
websocket?: Websocket;
dns4DomainName?: string;
}
```
Fields:
All fields are optional.
If a key is `undefined`, or `null`, a default value will be set.
-`host`: Listening IP address.
Default `0.0.0.0`.
-`port`: Libp2p TCP listening port.
Default `60000`.
Use `0` for random.
-`advertiseAddr`: External address to advertise to other nodes.
Can be ip4, ip6 or dns4, dns6.
If `null`, the multiaddress(es) generated from the ip and port specified in the config (or default ones) will be used.
Default: `null`.
-`nodeKey`: Secp256k1 private key in Hex format (`0x123...abc`).
Default random.
-`keepAliveInterval`: Interval in seconds for pinging peers to keep the connection alive.
Default `20`.
-`relay`: Enable relay protocol.
Default `true`.
-`relayTopics`: Array of pubsub topics that WakuRelay will automatically subscribe to when the node
starts
Default `[]`
-`gossipSubParameters`: custom gossipsub parameters. See `GossipSubParameters` section for defaults
-`minPeersToPublish`: The minimum number of peers required on a topic to allow broadcasting a message.
Default `0`.
-`legacyFilter`: Enable Legacy Filter protocol.
Default `false`.
-`discV5`: Enable DiscoveryV5.
Default `false`
-`discV5BootstrapNodes`: Array of bootstrap nodes ENR
-`discV5UDPPort`: UDP port for DiscoveryV5
Default `9000`
-`store`: Enable store protocol to persist message history
Default `false`
-`databaseURL`: url connection string. Accepts SQLite and PostgreSQL connection strings
Default: `sqlite3://store.db`
-`storeRetentionMaxMessages`: max number of messages to store in the database.
Default `10000`
-`storeRetentionTimeSeconds`: max number of seconds that a message will be persisted in the database.
Default `2592000` (30d)
-`websocket`: custom websocket support parameters. See `Websocket` section for defaults
-`dns4DomainName`: the domain name resolving to the node's public IPv4 address.
For example:
```json
{
"host": "0.0.0.0",
"port": 60000,
"advertiseAddr": "1.2.3.4",
"nodeKey": "0x123...567",
"keepAliveInterval": 20,
"relay": true,
"minPeersToPublish": 0
}
```
### `GossipsubParameters` type
Type holding custom gossipsub configuration:
```ts
interface GossipSubParameters {
D?: number;
D_low?: number;
D_high?: number;
D_score?: number;
D_out?: number;
HistoryLength?: number;
HistoryGossip?: number;
D_lazy?: number;
GossipFactor?: number;
GossipRetransmission?: number;
HeartbeatInitialDelayMs?: number;
HeartbeatIntervalSeconds?: number;
SlowHeartbeatWarning?: number;
FanoutTTLSeconds?: number;
PrunePeers?: number;
PruneBackoffSeconds?: number;
UnsubscribeBackoffSeconds?: number;
Connectors?: number;
MaxPendingConnections?: number;
ConnectionTimeoutSeconds?: number;
DirectConnectTicks?: number;
DirectConnectInitialDelaySeconds?: number;
OpportunisticGraftTicks?: number;
OpportunisticGraftPeers?: number;
GraftFloodThresholdSeconds?: number;
MaxIHaveLength?: number;
MaxIHaveMessages?: number;
IWantFollowupTimeSeconds?: number;
}
```
Fields:
All fields are optional.
If a key is `undefined`, or `null`, a default value will be set.
-`d`: optimal degree for a GossipSub topic mesh.
Default `6`
-`dLow`: lower bound on the number of peers we keep in a GossipSub topic mesh
Default `5`
-`dHigh`: upper bound on the number of peers we keep in a GossipSub topic mesh.
Default `12`
-`dScore`: affects how peers are selected when pruning a mesh due to over subscription.
Default `4`
-`dOut`: sets the quota for the number of outbound connections to maintain in a topic mesh.
Default `2`
-`historyLength`: controls the size of the message cache used for gossip.
Default `5`
-`historyGossip`: controls how many cached message ids we will advertise in IHAVE gossip messages.
Default `3`
-`dLazy`: affects how many peers we will emit gossip to at each heartbeat.
Default `6`
-`gossipFactor`: affects how many peers we will emit gossip to at each heartbeat.
Default `0.25`
-`gossipRetransmission`: controls how many times we will allow a peer to request the same message id through IWANT gossip before we start ignoring them.
Default `3`
-`heartbeatInitialDelayMs`: short delay in milliseconds before the heartbeat timer begins after the router is initialized.
Default `100` milliseconds
-`heartbeatIntervalSeconds`: controls the time between heartbeats.
Default `1` second
-`slowHeartbeatWarning`: duration threshold for heartbeat processing before emitting a warning.
Default `0.1`
-`fanoutTTLSeconds`: controls how long we keep track of the fanout state.
Default `60` seconds
-`prunePeers`: controls the number of peers to include in prune Peer eXchange.
Default `16`
-`pruneBackoffSeconds`: controls the backoff time for pruned peers.
Default `60` seconds
-`unsubscribeBackoffSeconds`: controls the backoff time to use when unsuscribing from a topic.
Default `10` seconds
-`connectors`: number of active connection attempts for peers obtained through PX.
Default `8`
-`maxPendingConnections`: maximum number of pending connections for peers attempted through px.
Default `128`
-`connectionTimeoutSeconds`: timeout in seconds for connection attempts.
Default `30` seconds
-`directConnectTicks`: the number of heartbeat ticks for attempting to reconnect direct peers that are not currently connected.
Default `300`
-`directConnectInitialDelaySeconds`: initial delay before opening connections to direct peers.
Default `1` second
-`opportunisticGraftTicks`: number of heartbeat ticks for attempting to improve the mesh with opportunistic grafting.
Default `60`
-`opportunisticGraftPeers`: the number of peers to opportunistically graft.
Default `2`
-`graftFloodThresholdSeconds`: If a GRAFT comes before GraftFloodThresholdSeconds has elapsed since the last PRUNE, then there is an extra score penalty applied to the peer through P7.
Default `10` seconds
-`maxIHaveLength`: max number of messages to include in an IHAVE message, also controls the max number of IHAVE ids we will accept and request with IWANT from a peer within a heartbeat.
Default `5000`
-`maxIHaveMessages`: max number of IHAVE messages to accept from a peer within a heartbeat.
Default `10`
-`iWantFollowupTimeSeconds`: Time to wait for a message requested through IWANT following an IHAVE advertisement.
Default `3` seconds
-`seenMessagesTTLSeconds`: configures when a previously seen message ID can be forgotten about.
Default `120` seconds
### `Websocket` type
Type holding custom websocket support configuration:
```ts
interface Websocket {
enabled?: bool;
host?: string;
port?: number;
secure?: bool;
certPath?: string;
keyPath?: string;
}
```
Fields:
All fields are optional.
If a key is `undefined`, or `null`, a default value will be set. If using `secure` websockets support, `certPath` and `keyPath` become mandatory attributes. Unless selfsigned certificates are used, it will probably make sense in the `JsonConfiguration` to specify the domain name used in the certificate in the `dns4DomainName` attribute.
-`enabled`: indicates if websockets support will be enabled
Default `false`
-`host`: listening address for websocket connections
Default `0.0.0.0`
-`port`: TCP listening port for websocket connection (`0` for random, binding to `443` requires root access)
Default `60001`, if secure websockets support is enabled, the default is `6443“`
-`secure`: enable secure websockets support
Default `false`
-`certPath`: secure websocket certificate path
-`keyPath`: secure websocket key path
### `extern int waku_new(char* jsonConfig, WakuCallBack onErrCb)`
Instantiates a Waku node.
**Parameters**
1.`char* jsonConfig`: JSON string containing the options used to initialize a waku node.
Type [`JsonConfig`](#jsonconfig-type).
It can be `NULL` to use defaults.
2.`WakuCallBack onErrCb`: [`WakuCallBack`](#wakucallback-type). Callback to be executed if the function fails
**Returns**
`int` with a status code. Possible values:
- 0 - The operation was completed successfuly.
- 1 - The operation failed for any reason. `onErrCb` will be executed with the reason the function execution failed.
- 2 - The function is missing the `onErrCb` callback
### `extern int waku_start(WakuCallBack onErrCb)`
Starts a Waku node mounting all the protocols that were enabled during the Waku node instantiation.
**Parameters**
1.`WakuCallBack onErrCb`: callback to be executed if the function fails
**Returns**
`int` with a status code. Possible values:
- 0 - The operation was completed successfuly.
- 1 - The operation failed for any reason. `onErrCb` will be executed with the reason the function execution failed.
- 2 - The function is missing the `onErrCb` callback
### `extern int waku_stop(WakuCallBack onErrCb)`
Stops a Waku node.
**Parameters**
1.`WakuCallBack onErrCb`: callback to be executed if the function fails
**Returns**
`int` with a status code. Possible values:
- 0 - The operation was completed successfuly.
- 1 - The operation failed for any reason. `onErrCb` will be executed with the reason the function execution failed.
- 2 - The function is missing the `onErrCb` callback
### `extern int waku_peerid(WakuCallBack onOkCb, WakuCallBack onErrCb)`
Get the peer ID of the waku node.
**Parameters**
1.`WakuCallBack onOkCb`: callback to be executed if the function is succesful
2.`WakuCallBack onErrCb`: callback to be executed if the function fails
**Returns**
`int` with a status code. Possible values:
- 0 - The operation was completed successfuly. `onOkCb` will receive the base58 encoded peer ID, for example `QmWjHKUrXDHPCwoWXpUZ77E8o6UbAoTTZwf1AD1tDC4KNP`
- 1 - The operation failed for any reason. `onErrCb` will be executed with the reason the function execution failed.
- 2 - The function is missing the `onOkCb` or `onErrCb` callback
### `extern int waku_listen_addresses(WakuCallBack onOkCb, WakuCallBack onErrCb)`
Get the multiaddresses the Waku node is listening to.
**Parameters**
1.`WakuCallBack onOkCb`: callback to be executed if the function is succesful
2.`WakuCallBack onErrCb`: callback to be executed if the function fails
**Returns**
`int` with a status code. Possible values:
- 0 - The operation was completed successfuly. `onOkCb` will receive a json array of multiaddresses.
The multiaddresses are `string`s. For example:
```json
[
"/ip4/127.0.0.1/tcp/30303",
"/ip4/1.2.3.4/tcp/30303",
"/dns4/waku.node.example/tcp/8000/wss"
]
```
- 1 - The operation failed for any reason. `onErrCb` will be executed with the reason the function execution failed.
- 2 - The function is missing the `onOkCb` and `onErrCb` callback
- 0 - The operation was completed successfuly. `onOkCb` will receive the content topic formatted according to [RFC 23](../../../informational/23/topics.md): `/{application-name}/{version-of-the-application}/{content-topic-name}/{encoding}`
- 0 - The operation was completed successfuly. `onOkCb` will get populated with a pubsub topic formatted according to [RFC 23](../../../informational/23/topics.md): `/waku/2/{topic-name}/{encoding}`
2.`char* pubsubTopic`: pubsub topic on which to publish the message.
If `NULL`, it uses the default pubsub topic.
3.`int timeoutMs`: Timeout value in milliseconds to execute the call.
If the function execution takes longer than this value,
the execution will be canceled and an error returned.
Use `0` for no timeout.
4.`WakuCallBack onOkCb`: callback to be executed if the function is succesful
5.`WakuCallBack onErrCb`: callback to be executed if the function fails
If the execution is successful, the `result` field contains the message ID.
**Returns**
`int` with a status code. Possible values:
- 0 - The operation was completed successfuly. `onOkCb` will get populated with the message ID
- 1 - The operation failed for any reason. `onErrCb` will be executed with the reason the function execution failed.
- 2 - The function is missing the `onOkCb` or `onErrCb` callback
### `extern int waku_relay_enough_peers(char* pubsubTopic, WakuCallBack onOkCb, WakuCallBack onErrCb)`
Determine if there are enough peers to publish a message on a given pubsub topic.
**Parameters**
1.`char* pubsubTopic`: Pubsub topic to verify.
If `NULL`, it verifies the number of peers in the default pubsub topic.
2.`WakuCallBack onOkCb`: callback to be executed if the function is succesful
3.`WakuCallBack onErrCb`: callback to be executed if the function fails
**Returns**
`int` with a status code. Possible values:
- 0 - The operation was completed successfuly. `onOkCb` will receive a string `boolean` indicating whether there are enough peers, i.e. `true` or `false`
- 1 - The operation failed for any reason. `onErrCb` will be executed with the reason the function execution failed.
- 2 - The function is missing the `onOkCb` or `onErrCb` callback
### `extern int waku_relay_subscribe(char* topic, WakuCallBack onErrCb)`
Subscribe to a Waku Relay pubsub topic to receive messages.
**Parameters**
1.`char* topic`: Pubsub topic to subscribe to.
If `NULL`, it subscribes to the default pubsub topic.
2.`WakuCallBack onErrCb`: callback to be executed if the function fails
**Returns**
`int` with a status code. Possible values:
- 0 - The operation was completed successfuly.
- 1 - The operation failed for any reason. `onErrCb` will be executed with the reason the function execution failed.
- 2 - The function is missing the `onErrCb` callback
**Events**
When a message is received, a ``"message"` event` is emitted containing the message, pubsub topic, and node ID in which
the message was received.
The `event` type is [`JsonMessageEvent`](#jsonmessageevent-type).
### `extern int waku_filter_ping(char* peerID, int timeoutMs, WakuCallBack onErrCb)`
Used to know if a service node has an active subscription for this client
**Parameters**
1.`char* peerID`: Peer ID to check for an active subscription
The peer must be already known.
It must have been added before with [`waku_add_peer`](#extern-char-waku_add_peerchar-address-char-protocolid)
or previously dialed with [`waku_connect_peer`](#extern-char-waku_connect_peerchar-address-int-timeoutms).
2.`int timeoutMs`: Timeout value in milliseconds to execute the call.
If the function execution takes longer than this value,
the execution will be canceled and an error returned.
Use `0` for no timeout.
3.`WakuCallBack onErrCb`: callback to be executed if the function fails
**Returns**
`int` with a status code. Possible values:
- 0 - The operation was completed successfuly.
- 1 - The operation failed for any reason. `onErrCb` will be executed with the reason the function execution failed.
- 2 - The function is missing the `onErrCb` callback
### `extern int waku_filter_unsubscribe(filterJSON *C.char, char* peerID, int timeoutMs, WakuCallBack onErrCb)`
Sends a requests to a service node to stop pushing messages matching this filter to this client. It might be used to modify an existing subscription by providing a subset of the original filter criteria
**Parameters**
1.`char* filterJSON`: JSON string containing the [`FilterSubscription`](#filtersubscription-type) criteria to unsubscribe from
2.`char* peerID`: Peer ID to unsubscribe from
The peer must be already known.
It must have been added before with [`waku_add_peer`](#extern-char-waku_add_peerchar-address-char-protocolid)
or previously dialed with [`waku_connect_peer`](#extern-char-waku_connect_peerchar-address-int-timeoutms).
3.`int timeoutMs`: Timeout value in milliseconds to execute the call.
If the function execution takes longer than this value,
the execution will be canceled and an error returned.
Use `0` for no timeout.
4.`WakuCallBack onErrCb`: callback to be executed if the function fails
**Returns**
`int` with a status code. Possible values:
- 0 - The operation was completed successfuly.
- 1 - The operation failed for any reason. `onErrCb` will be executed with the reason the function execution failed.
- 2 - The function is missing the `onOkCb` or `onErrCb` callback
### `extern int waku_filter_unsubscribe_all(char* peerID, int timeoutMs, WakuCallBack onOkCb, WakuCallBack onErrCb)`
Sends a requests to a service node (or all service nodes) to stop pushing messages
**Parameters**
1.`char* peerID`: Peer ID to unsubscribe from
The peer must be already known.
It must have been added before with [`waku_add_peer`](#extern-char-waku_add_peerchar-address-char-protocolid)
or previously dialed with [`waku_connect_peer`](#extern-char-waku_connect_peerchar-address-int-timeoutms).
Use `NULL` to unsubscribe from all peers with active subscriptions
2.`int timeoutMs`: Timeout value in milliseconds to execute the call.
If the function execution takes longer than this value,
the execution will be canceled and an error returned.
Use `0` for no timeout.
3.`WakuCallBack onOkCb`: callback to be executed if the function is succesful
4.`WakuCallBack onErrCb`: callback to be executed if the function fails
**Returns**
`int` with a status code. Possible values:
- 0 - The operation was completed successfuly. `onOkCb` will receive an array with information about the state of each unsubscription attempt (one per peer)
```
[
{
"peerID": ....,
"error": "" // Empty if succesful
},
...
]
```
- 1 - The operation failed for any reason. `onErrCb` will be executed with the reason the function execution failed.
- 2 - The function is missing the `onOkCb` or `onErrCb` callback
## Waku Legacy Filter
### `extern int waku_legacy_filter_subscribe(char* filterJSON, char* peerID, int timeoutMs, WakuCallBack onErrCb)`
Creates a subscription in a lightnode for messages that matches a content filter and optionally a [PubSub `topic`](https://github.com/libp2p/specs/blob/master/pubsub/README.md#the-topic-descriptor).
**Parameters**
1.`char* filterJSON`: JSON string containing the [`LegacyFilterSubscription`](#legacyfiltersubscription-type) to subscribe to.
2.`char* peerID`: Peer ID to subscribe to.
The peer must be already known.
It must have been added before with [`waku_add_peer`](#extern-char-waku_add_peerchar-address-char-protocolid)
or previously dialed with [`waku_connect_peer`](#extern-char-waku_connect_peerchar-address-int-timeoutms).
Use `NULL` to automatically select a node.
3.`int timeoutMs`: Timeout value in milliseconds to execute the call.
If the function execution takes longer than this value,
the execution will be canceled and an error returned.
Use `0` for no timeout.
4.`WakuCallBack onErrCb`: callback to be executed if the function fails
**Returns**
`int` with a status code. Possible values:
- 0 - The operation was completed successfuly.
- 1 - The operation failed for any reason. `onErrCb` will be executed with the reason the function execution failed.
- 2 - The function is missing the `onErrCb` callback
**Events**
When a message is received, a ``"message"` event` is emitted containing the message, pubsub topic, and node ID in which
the message was received.
The `event` type is [`JsonMessageEvent`](#jsonmessageevent-type).
### `extern int waku_legacy_filter_unsubscribe(char* filterJSON, int timeoutMs, WakuCallBack onErrCb)`
Removes subscriptions in a light node matching a content filter and, optionally, a [PubSub `topic`](https://github.com/libp2p/specs/blob/master/pubsub/README.md#the-topic-descriptor).
**Parameters**
1.`char* filterJSON`: JSON string containing the [`LegacyFilterSubscription`](#filtersubscription-type).
2.`int timeoutMs`: Timeout value in milliseconds to execute the call.
If the function execution takes longer than this value,
the execution will be canceled and an error returned.
Use `0` for no timeout.
3.`WakuCallBack onErrCb`: callback to be executed if the function fails
**Returns**
`int` with a status code. Possible values:
- 0 - The operation was completed successfuly.
- 1 - The operation failed for any reason. `onErrCb` will be executed with the reason the function execution failed.
- 2 - The function is missing the `onErrCb` callback
## Waku Lightpush
### `extern int waku_lightpush_publish(char* messageJSON, char* topic, char* peerID, int timeoutMs, WakuCallBack onOkCb, WakuCallBack onErrCb)`
2.`char* pubsubTopic`: pubsub topic on which to publish the message.
If `NULL`, it uses the default pubsub topic.
3.`char* peerID`: Peer ID supporting the lightpush protocol.
The peer must be already known.
It must have been added before with [`waku_add_peer`](#extern-char-waku_add_peerchar-address-char-protocolid)
or previously dialed with [`waku_connect_peer`](#extern-char-waku_connect_peerchar-address-int-timeoutms).
Use `NULL` to automatically select a node.
3.`int timeoutMs`: Timeout value in milliseconds to execute the call.
If the function execution takes longer than this value,
the execution will be canceled and an error returned.
Use `0` for no timeout.
4.`WakuCallBack onOkCb`: callback to be executed if the function is succesful
5.`WakuCallBack onErrCb`: callback to be executed if the function fails
Note: `messageJson.version` is overwritten to `0`.
**Returns**
`int` with a status code. Possible values:
- 0 - The operation was completed successfuly. `onOkCb` will receive the message ID
- 1 - The operation failed for any reason. `onErrCb` will be executed with the reason the function execution failed.
- 2 - The function is missing the `onOkCb` or `onErrCb` callback
## Waku Store
### `extern int waku_store_query(char* queryJSON, char* peerID, int timeoutMs, WakuCallBack onOkCb, WakuCallBack onErrCb)`
Retrieves historical messages on specific content topics. This method may be called with [`PagingOptions`](#pagingoptions-type),
to retrieve historical messages on a per-page basis. If the request included [`PagingOptions`](#pagingoptions-type), the node
must return messages on a per-page basis and include [`PagingOptions`](#pagingoptions-type) in the response. These [`PagingOptions`](#pagingoptions-type)
must contain a cursor pointing to the Index from which a new page can be requested.
**Parameters**
1.`char* queryJSON`: JSON string containing the [`StoreQuery`](#storequery-type).
2.`char* peerID`: Peer ID supporting the store protocol.
The peer must be already known.
It must have been added before with [`waku_add_peer`](#extern-char-waku_add_peerchar-address-char-protocolid)
or previously dialed with [`waku_connect_peer`](#extern-char-waku_connect_peerchar-address-int-timeoutms).
3.`int timeoutMs`: Timeout value in milliseconds to execute the call.
If the function execution takes longer than this value,
the execution will be canceled and an error returned.
Use `0` for no timeout.
4.`WakuCallBack onOkCb`: callback to be executed if the function is succesful
5.`WakuCallBack onErrCb`: callback to be executed if the function fails
**Returns**
`int` with a status code. Possible values:
- 0 - The operation was completed successfuly. `onOkCb` will receive a [`StoreResponse`](#storeresponse-type).
- 1 - The operation failed for any reason. `onErrCb` will be executed with the reason the function execution failed.
- 2 - The function is missing the `onOkCb` or `onErrCb` callback
### `extern int waku_store_local_query(char* queryJSON, WakuCallBack onOkCb, WakuCallBack onErrCb)`
Retrieves locally stored historical messages on specific content topics. This method may be called with [`PagingOptions`](#pagingoptions-type),
to retrieve historical messages on a per-page basis. If the request included [`PagingOptions`](#pagingoptions-type), the node
must return messages on a per-page basis and include [`PagingOptions`](#pagingoptions-type) in the response. These [`PagingOptions`](#pagingoptions-type)
must contain a cursor pointing to the Index from which a new page can be requested.
**Parameters**
1.`char* queryJSON`: JSON string containing the [`StoreQuery`](#storequery-type).
2.`int timeoutMs`: Timeout value in milliseconds to execute the call.
If the function execution takes longer than this value,
the execution will be canceled and an error returned.
Use `0` for no timeout.
3.`WakuCallBack onOkCb`: callback to be executed if the function is succesful
4.`WakuCallBack onErrCb`: callback to be executed if the function fails
**Returns**
`int` with a status code. Possible values:
- 0 - The operation was completed successfuly. `onOkCb` will receive a [`StoreResponse`](#storeresponse-type).
- 1 - The operation failed for any reason. `onErrCb` will be executed with the reason the function execution failed.
- 2 - The function is missing the `onOkCb` or `onErrCb` callback
2.`char* symmetricKey`: hex encoded secret key to be used for encryption.
3.`char* optionalSigningKey`: hex encoded private key to be used to sign the message.
4.`WakuCallBack onOkCb`: callback to be executed if the function is succesful
5.`WakuCallBack onErrCb`: callback to be executed if the function fails
Note: `messageJson.version` is overwritten to `1`.
**Returns**
`int` with a status code. Possible values:
- 0 - The operation was completed successfuly. `onOkCb` will receive the encrypted waku message which can be broadcasted with relay or lightpush protocol publish functions.
- 1 - The operation failed for any reason. `onErrCb` will be executed with the reason the function execution failed.
- 2 - The function is missing the `onOkCb` or `onErrCb` callback
2.`char* publicKey`: hex encoded public key to be used for encryption.
3.`char* optionalSigningKey`: hex encoded private key to be used to sign the message.
4.`WakuCallBack onOkCb`: callback to be executed if the function is succesful
5.`WakuCallBack onErrCb`: callback to be executed if the function fails
Note: `messageJson.version` is overwritten to `1`.
**Returns**
`int` with a status code. Possible values:
- 0 - The operation was completed successfuly. `onOkCb` will receive the encrypted waku message which can be broadcasted with relay or lightpush protocol publish functions.
- 1 - The operation failed for any reason. `onErrCb` will be executed with the reason the function execution failed.
- 2 - The function is missing the `onOkCb` or `onErrCb` callback