-
Notifications
You must be signed in to change notification settings - Fork 0
/
node.hxx
54 lines (51 loc) · 1.26 KB
/
node.hxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* declarations of data structures used */
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <arpa/inet.h>
#include <string>
#define M 8
using namespace std;
/*info is the information of the machine */
class info
{
public:
// Constructor
info(unsigned long _ip = 0,int _port = 0);
info(string _ip,string _port);
info(info&); // copy constructor
~info(); // destructor
unsigned long get_ip();
int get_port();
unsigned long long get_mid();
unsigned long ip;
int port;
unsigned long long mid;
};
unsigned long long oat_hash(string s);
// Node denotes node in the network */
class Node
{
public:
// constructor to set things
Node(unsigned long _ip = 0, int _port = 0);
//Node(string ip, string port);
Node(Node&);
Node(string _ip, string _port);
// destructor
~Node();
// get set fucntions for successor and predecessor
info get_successor();
info get_predecessor();
void set_successor(info&);
void set_predecessor(info&);
unsigned long get_ip();
int get_port();
unsigned long long get_mid();
private:
unsigned long ip;
int port;
unsigned long long machine_id;
info successor; // successor has hash value just greater than current's machine id
info predecessor; // predecessor has hash value just lesser than current's machine_id
};