#include "lib.h"
#include "list.h"
#include "uuid.h"
#include "enchufe.h"
Go to the source code of this file.
|
| struct | DNode |
| | Saves the connection data. More...
|
| struct | DNodeInfo |
| | This carries all the necessary information that a chunk should have. More...
|
◆ DNODE_TABLE
| #define DNODE_TABLE "data/dnode.bin" |
◆ DefList()
◆ DNode_deserialize()
◆ DNode_get_db()
| ListDNode DNode_get_db |
( |
void | | ) |
|
Get the DNode table from the database.
- Returns
- a List of DNode's
◆ DNode_set_db()
| void DNode_set_db |
( |
ListDNode | dnodes | ) |
|
Write the database with the List of DNode's.
◆ DNodeInfo_deserialize()
Deserialize a Buffer into a List of DNodeInfo's.
Caller must free memory in DNodeInfo.address.
- Parameters
-
| buffer | The Buffer you want to deserialize |
- Returns
- The List of DNodeInfo's that the Buffer represents
◆ DNodeInfo_serialize()
◆ insert()
| ListDNodeInfo insert |
( |
ListDNodeInfo | l, |
|
|
DNodeInfo | a ) |
Insert a DNodeInfo into a ListDNodeInfo in a sorted fashion.
This is really just a helper function for sort(ListDNodeInfo l). Here is a Haskell implementation of it:
insert :: [Int] -> Int -> [Int]
insert [] a = [a]
insert (x:xs) a = if x > a then a:x:xs else x:insert xs a
- Parameters
-
| l | the ListDNodeInfo that you want to insert into |
| a | the DNodeInfo that you want to insert |
- Returns
- a ListDNodeInfo with a placed depending on its sequence number
◆ insert_into_dnode()
| void insert_into_dnode |
( |
IPv4 | address, |
|
|
Port | port ) |
INSERT into the DNode table.
- Parameters
-
| address | the URI address |
| port | the port of the connection |
◆ ListDNode_deserialize()
| ListDNode ListDNode_deserialize |
( |
Buffer | buf | ) |
|
◆ ListDNode_serialize()
| Buffer ListDNode_serialize |
( |
ListDNode | list | ) |
|
Serialize a List of DNode's into a Buffer.
Caller must free memory in Buffer.buf.
- Parameters
-
| list | the List of DNode's that you want to serialize |
- Returns
- the Buffer that the ListDNode represents
◆ ListDNodeInfo_deserialize()
| ListDNodeInfo ListDNodeInfo_deserialize |
( |
Buffer | buf | ) |
|
Deserialize a Buffer into a List of DNodeInfo's.
Caller must free memory in DNodeInfo.address.
- Parameters
-
| buffer | The Buffer you want to deserialize |
- Returns
- The List of DNodeInfo's that the Buffer represents
◆ ListDNodeInfo_serialize()
| Buffer ListDNodeInfo_serialize |
( |
ListDNodeInfo | list | ) |
|
Serialize a ListDNodeInfo to a buffer.
- Parameters
-
| dinfo | the ListDNodeInfo you want to serialize |
- Returns
- the Buffer thet tha ListDNodeInfo represents
◆ print_dnode()
| void print_dnode |
( |
DNode | dnode | ) |
|
Print a DNode's data as a tuple.
- Parameters
-
| dnode | the DNode to be printed |
◆ select_from_dnode()
| ListDNode select_from_dnode |
( |
UUID * | nid, |
|
|
IPv4 * | address, |
|
|
Port * | port ) |
SELECT from the DNode table.
- Parameters
-
| nid | the DNode's ID or NULL |
| address | the host's address or PULL |
| port | the host's Port or NULL |
- Returns
- a ListDNode of the possible matches
◆ sort()
| ListDNodeInfo sort |
( |
ListDNodeInfo | l | ) |
|
Sort a ListDNodeInfo depending on the sequence numbers of its entries.
sort :: [Int] -> [Int]
sort = foldl insert []
- Parameters
-
| l | the ListDNodeInfo you want to sort |
- Returns
- a sorted version of l