Files
ToastyFS/include/toastyfs.h
T
Claude 723fc7cf76 Complete client library refactoring: fill all placeholders and implement missing functions
- Add REPLICATION_FACTOR and CHUNK_SIZE constants to config.h
- Add proper error codes (REJECTED, FULL, NOT_FOUND, TRANSFER_FAILED, etc.) to toastyfs.h
- Implement compute_chunk_hash() for deterministic chunk hashing
- Implement replay_request() to resend operations after leader redirect
- Implement send_message_to_server_ex() for sending messages with trailing data
- Implement choose_store_locations_for_chunk() to pick REPLICATION_FACTOR servers
- Fix begin_transfers() to handle both StoreChunk (PUT) and FetchChunk (GET)
- Complete toastyfs_async_put(): chunk splitting, hashing, data copy, metadata setup
- Complete toastyfs_async_get()/delete(): key setup, step/time initialization
- Fix get_result(): use actual transfer sizes instead of fixed chunk_size, free transfer data
- Replace all xxx placeholders and TOASTYFS_ERROR_XXX with proper values
- Add chunk_sizes[] tracking and put_data lifetime management
- Implement random_client.c: rng(), choose_random_oper(), proper API call arguments

https://claude.ai/code/session_01TkNavR4qyZcTuXMPmrtWUJ
2026-02-21 13:03:13 +00:00

55 lines
1.5 KiB
C

#ifndef TOASTYFS_INCLUDED
#define TOASTYFS_INCLUDED
#include <stdint.h>
typedef enum {
TOASTYFS_RESULT_VOID,
TOASTYFS_RESULT_PUT,
TOASTYFS_RESULT_GET,
TOASTYFS_RESULT_DELETE,
} ToastyFS_ResultType;
typedef enum {
TOASTYFS_ERROR_VOID,
TOASTYFS_ERROR_OUT_OF_MEMORY,
TOASTYFS_ERROR_UNEXPECTED_MESSAGE,
TOASTYFS_ERROR_REJECTED,
TOASTYFS_ERROR_FULL,
TOASTYFS_ERROR_NOT_FOUND,
TOASTYFS_ERROR_TRANSFER_FAILED,
} ToastyFS_Error;
typedef struct {
ToastyFS_ResultType type;
ToastyFS_Error error;
char *data;
int size;
} ToastyFS_Result;
typedef struct ToastyFS ToastyFS;
ToastyFS *toastyfs_init(uint64_t client_id, char **addrs, int num_addrs);
void toastyfs_free(ToastyFS *tfs);
void toastyfs_process_events(ToastyFS *tfs, void **ctxs, struct pollfd *pdata, int pnum);
int toastyfs_register_events(ToastyFS *tfs, void **ctxs, struct pollfd *pdata, int pcap);
int toastyfs_async_put(ToastyFS *tfs, char *key, int key_len,
char *data, int data_len);
int toastyfs_async_get(ToastyFS *tfs, char *key, int key_len);
int toastyfs_async_delete(ToastyFS *tfs, char *key, int key_len);
ToastyFS_Result toastyfs_get_result(ToastyFS *tfs);
int toastyfs_put(ToastyFS *tfs, char *key, int key_len,
char *data, int data_len, ToastyFS_Result *res);
int toastyfs_get(ToastyFS *tfs, char *key, int key_len, ToastyFS_Result *res);
int toastyfs_delete(ToastyFS *tfs, char *key, int key_len, ToastyFS_Result *res);
#endif // TOASTYFS_INCLUDED