Toychain!
A toy blockchain in C
vote.h
Go to the documentation of this file.
1#ifndef _VOTE_H_
2#define _VOTE_H_
3
4#include "lib/sign.h"
5#include "lib/dataio.h"
6#include "lib/types.h"
7#include <stddef.h>
8
17typedef struct hashcell {
18 Key* key;
19 int val;
21
25typedef struct hashtable {
26 HashCell** tab;
27 int size;
29
31HashCell* create_hashcell(const Key* key);
32void free_hashcell(HashCell* hc);
33uint32 hash_function(const Key* key, int size);
34uint32 find_position(const HashTable* t, const Key* k);
35HashTable* create_hashtable(const CellKey* keys, size_t size);
37Key* compute_winner(const CellProtected* decl, const CellKey* cadidates, const CellKey* voters, int sizeC, int sizeV);
38
39#endif
header for dataio.c
header of sign.c
Definition: rsa.h:16
Definition: dataio.h:20
Definition: dataio.h:28
Definition: vote.h:17
Definition: vote.h:25
a file with comfy aliases for long type signatures
#define uint32
alias for unsigned long int
Definition: types.h:22
void free_hashcell(HashCell *hc)
Free a HasCell object.
Definition: vote.c:44
HashCell * create_hashcell_raw(Key *key)
Create a hashcell raw object. Takes ownership of key.
Definition: vote.c:20
HashCell * create_hashcell(const Key *key)
Create a hashcell object. Copies key.
Definition: vote.c:36
void free_hashtable(HashTable *t)
Free a HashTable object and all the elements of the table. (Correspond to delete_hashtable in the pro...
Definition: vote.c:129
HashTable * create_hashtable(const CellKey *keys, size_t size)
Create a HashTable object containing keys elements. Keys position are found with find_position()....
Definition: vote.c:93
Key * compute_winner(const CellProtected *decl, const CellKey *cadidates, const CellKey *voters, int sizeC, int sizeV)
Simulates an election process and returns the winner. Checks if declarations are valid and update vot...
Definition: vote.c:149
uint32 hash_function(const Key *key, int size)
Hash function for Key arrays (HashTable).
Definition: vote.c:56
struct hashtable HashTable
uint32 find_position(const HashTable *t, const Key *k)
Find the position to place k at in the HasTable t. If the position in the array is taken,...
Definition: vote.c:71
struct hashcell HashCell