ddat interop with dat js cable interop with cabal js ddat's frontend = dat-thang cable fe = cable-thang dillo support based on cel's dillo-dat bootstrap node xplatform support Signed-off-by: divo <418@cryspace.space>
45 lines
1.8 KiB
C
45 lines
1.8 KiB
C
#ifndef SLEEP_REPLICATION_H
|
|
#define SLEEP_REPLICATION_H
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include "sleep_feed.h"
|
|
#include "sleep_bitfield.h"
|
|
#include "sleep_proof.h"
|
|
|
|
#define SLEEP_REPLICATION_QUEUE 128u
|
|
typedef struct sleep_replication_request { uint64_t index; uint64_t bytes; int hash; int nodes; } sleep_replication_request_t;
|
|
typedef struct sleep_replication {
|
|
sleep_feed_t *feed;
|
|
uint64_t channel;
|
|
uint64_t remote_length;
|
|
sleep_bitfield_t remote_bitfield;
|
|
sleep_replication_request_t requests[SLEEP_REPLICATION_QUEUE];
|
|
size_t request_head, request_count;
|
|
int live, uploading, downloading;
|
|
} sleep_replication_t;
|
|
|
|
int sleep_replication_init(sleep_replication_t *replication,
|
|
sleep_feed_t *feed, uint64_t channel);
|
|
int sleep_replication_have(sleep_replication_t *replication,
|
|
uint64_t start, uint64_t length);
|
|
int sleep_replication_unhave(sleep_replication_t *replication,
|
|
uint64_t start, uint64_t length);
|
|
int sleep_replication_want(sleep_replication_t *replication,
|
|
uint64_t start, uint64_t length);
|
|
int sleep_replication_request(sleep_replication_t *replication,
|
|
const sleep_replication_request_t *request);
|
|
int sleep_replication_next(sleep_replication_t *replication,
|
|
sleep_replication_request_t *request);
|
|
int sleep_replication_complete(sleep_replication_t *replication,
|
|
uint64_t index);
|
|
int sleep_replication_is_requested(const sleep_replication_t *replication,
|
|
uint64_t index);
|
|
int sleep_replication_unwant(sleep_replication_t *replication,
|
|
uint64_t start, uint64_t length);
|
|
void sleep_replication_clear_requests(sleep_replication_t *replication);
|
|
int sleep_replication_receive(sleep_replication_t *replication,
|
|
const uint8_t *block, size_t block_len,
|
|
const sleep_proof_t *proof,
|
|
const uint8_t feed_public_key[32]);
|
|
#endif
|