@@ -250,6 +250,34 @@ bool is_online(Peers peers, Peer peer)
250250 return ((peers .online >> peer ) & 1 ) != 0 ;
251251}
252252
253+ /// @brief Save the given Stash.
254+ ///
255+ /// @details When called, the stash for the given peer will be stored in RAM.
256+ /// Calling load_stash() for the same peer will return that stash.
257+ /// On exit, the runtime will persist the stash in FS.
258+ /// Next time the app starts, calling load_stash() will restore the stash
259+ /// saved earlier.
260+ void save_stash (Peer p , Stash s )
261+ {
262+ _ffb_save_stash (p , (int )s .head , s .size );
263+ }
264+
265+ /// @brief Load Stash saved earlier (in this or previous run) by save_stash.
266+ ///
267+ /// @details The buffer should be big enough to fit the stash.
268+ /// If it's not, the stash will be truncated.
269+ /// If there is no stash or it's empty, nil is returned.
270+ ///
271+ /// If the given buffer is nil, a new buffer will be allocated
272+ /// big enough to fit the biggest allowed stash. At the moment, it is 80 bytes.
273+ Stash load_stash (Peer p , Buffer s )
274+ {
275+ Stash res ;
276+ res .size = _ffb_load_stash (p , (int )s .head , s .size );
277+ res .head = s .head ;
278+ return res ;
279+ }
280+
253281// -- MISC -- //
254282
255283/// @brief Write a debug message.
0 commit comments