Next: , Up: Storing peer-specific data using the PEERSTORE service   [Contents]


4.6.1 Storing records

To store a new record, use the following function:

struct GNUNET_PEERSTORE_StoreContext *
GNUNET_PEERSTORE_store (struct GNUNET_PEERSTORE_Handle *h,
                        const char *sub_system,
                        const struct GNUNET_PeerIdentity *peer,
                        const char *key,
                        const void *value,
                        size_t size,
                        struct GNUNET_TIME_Absolute expiry,
                        enum GNUNET_PEERSTORE_StoreOption options,
                        GNUNET_PEERSTORE_Continuation cont,
                        void *cont_cls);

The options parameter can either be GNUNET_PEERSTORE_STOREOPTION_MULTIPLE which means that multiple values can be stored under the same key combination (subsystem, peerid, key), or GNUNET_PEERSTORE_STOREOPTION_REPLACE which means that PEERSTORE will replace any existing values under the given key combination (subsystem, peerid, key) with the new given value.

The continuation function cont will be called after the store request is successfully sent to the PEERSTORE service. This does not guarantee that the record is successfully stored, only that it was received by the service.

The GNUNET_PEERSTORE_store function returns a handle to the store operation. This handle can be used to cancel the store operation only before the continuation function is called:

void
GNUNET_PEERSTORE_store_cancel (struct GNUNET_PEERSTORE_StoreContext
                               *sc);