-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathUID_bchainBTC.h
More file actions
90 lines (73 loc) · 2.68 KB
/
UID_bchainBTC.h
File metadata and controls
90 lines (73 loc) · 2.68 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
* Copyright (c) 2016-2018. Uniquid Inc. or its affiliates. All Rights Reserved.
*
* License is in the "LICENSE" file accompanying this file.
* See the License for the specific language governing permissions and limitations under the License.
*/
/**
* @file UID_bchainBTC.h
*
* @date 5/aug/2016
* @author M. Palumbi
*/
#ifndef __UID_BCHAINBTC_H
#define __UID_BCHAINBTC_H
#include <stdint.h>
#include <pthread.h>
#include "UID_globals.h"
#include "UID_identity.h"
#ifndef UID_CONTRACTS_CACHE_SIZE
#define UID_CONTRACTS_CACHE_SIZE 200 // number of locally cached contracts
#endif // #ifndef UID_CONTRACTS_CACHE_SIZE
#ifndef UID_CLIENT_CACHE_SIZE
#define UID_CLIENT_CACHE_SIZE 50 // number of locally cached client contracts
#endif // #ifndef UID_CLIENT_CACHE_SIZE
#define PROFILE_SIZE 80 // OP_RETURN lenght...
#define UID_NAME_LENGHT 64
#define UID_APPLIANCE "http://appliance3.uniquid.co:8080/insight-api"
//#define UID_APPLIANCE "http://appliance1.uniquid.co:3001/insight-api"
//#define UID_APPLIANCE "http://appliance4.uniquid.co:3001/insight-api"
#define UID_GETTXS "%s/addr/%s", UID_pApplianceURL
#define UID_SENDTX "%s/tx/send", UID_pApplianceURL
#define UID_GETCONTRACT "%s/tx/%s", UID_pApplianceURL
extern char *UID_pApplianceURL;
#define UID_SMARTC_INITIALIZER {0,{0},{0},0,0}
#define UID_CACHE_BUFFER_INITIALIZER { { { {0},{0},UID_SMARTC_INITIALIZER,{0} } }, 0, { { {0},{0},{0},{0} } }, 0, PTHREAD_MUTEX_INITIALIZER }
typedef struct {
uint8_t version;
uint8_t bit_mask[18];
// uint8_t n_di_n;
// uint8_t guarantor[3][20];
uint8_t dummy[3*20+1-16];
int64_t since;
int64_t until;
} UID_smart_contract;
/// trick to raise a compiler error if the size of the struct is different than expected
typedef char assertion_on_mystruct[( sizeof(UID_smart_contract)==PROFILE_SIZE )*2-1 ];
typedef struct
{
BTC_Address serviceUserAddress;
BTC_Address serviceProviderAddress;
UID_smart_contract profile;
UID_Bip32Path path;
} UID_SecurityProfile;
typedef struct
{
char serviceProviderName[UID_NAME_LENGHT];
BTC_Address serviceProviderAddress;
BTC_Address serviceUserAddress;
UID_Bip32Path path;
} UID_ClientProfile;
typedef struct {
UID_SecurityProfile contractsCache[UID_CONTRACTS_CACHE_SIZE];
int validCacheEntries;
UID_ClientProfile clientCache[UID_CLIENT_CACHE_SIZE];
int validClientEntries;
pthread_mutex_t in_use;
} cache_buffer;
int UID_getContracts(cache_buffer **cache);
UID_SecurityProfile *UID_matchContract(BTC_Address serviceUserAddress);
UID_ClientProfile *UID_matchProvider(char *name);
int UID_insertProviderChannel(UID_SecurityProfile *channel);
int UID_insertUserChannel(UID_ClientProfile *channel);
#endif