Statistics
| Branch: | Revision:

pstreamer / src / transaction.h @ ffebdf87

History | View | Annotate | Download (1.76 KB)

1
/*
2
 * Copyright (c) 2010-2011 Stefano Traverso
3
 * Copyright (c) 2010-2011 Csaba Kiraly
4
 * Copyright (c) 2017 Luca Baldesi
5
 *
6
 * This file is part of PeerStreamer.
7
 *
8
 * PeerStreamer is free software: you can redistribute it and/or
9
 * modify it under the terms of the GNU Affero General Public License as
10
 * published by the Free Software Foundation, either version 3 of the
11
 * License, or (at your option) any later version.
12
 *
13
 * PeerStreamer is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero
16
 * General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Affero General Public License
19
 * along with PeerStreamer.  If not, see <http://www.gnu.org/licenses/>.
20
 *
21
 */
22

    
23
#ifndef TRANSACTION_H
24
#define TRANSACTION_H
25

    
26
#include <stdbool.h>
27
#include <net_helper.h>
28

    
29
/* timeout of the offers thread. If it is not updated, it is deleted */
30
#define TRANS_ID_MAX_LIFETIME 10.0
31

    
32
struct service_times_element;
33

    
34
// register the moment when a transaction is started
35
// return a  new transaction id
36
uint16_t transaction_create(struct service_times_element ** head, struct nodeID *id);
37

    
38
// Add the moment I received a positive select in a list
39
// return true if a valid trans_id is found
40
bool transaction_reg_accept(struct service_times_element * head, uint16_t trans_id,const struct nodeID *id);
41

    
42
// Used to get the time elapsed from the moment I get a positive select to the moment i get the ACK
43
// related to the same chunk
44
// it return -1.0 in case no trans_id is found
45
double transaction_remove(struct service_times_element ** head, uint16_t trans_id);
46

    
47
void transaction_destroy(struct service_times_element ** head);
48

    
49
#endif // TRANSACTION_H