-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathHost.js
More file actions
130 lines (123 loc) · 3.7 KB
/
Copy pathHost.js
File metadata and controls
130 lines (123 loc) · 3.7 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import {siacCommand, siacPostDataCommand} from './helper.js';
export class Host{
constructor(){
}
getHostInfo(){
return siacCommand('host','GET');/*.then(d=>{
console.log('host stats',d);
}).catch(e=>{
console.error('ERROR GETTING HOST INFO',e);
});*/
}
getHostBandwidth(){
siacCommand('host/bandwidth','GET').then(d=>{
console.log('host bandwidth stats',d);
}).catch(e=>{
console.error('ERROR GETTING HOST BANDWIDTH INFO',e);
});
}
updateHostParameters(options){
let optsString = '';
Object.keys(options).map((key,i)=>{
let delim = i == 0 ? '?' : '&';
optsString += delim;
optsString += key+'='+options[key];
});
//acceptingcontracts boolean
//maxdownloadbatchsize bytes
//maxduration blocks
//maxrevisebatchsize bytes
//netaddress string
//windowsize blocks
//collateral hastings/byte/block
//collateralbudget hastings
//maxcollateral hastings
//minbaserpcprice hastings
//mincontractprice hastings
//minsectoraccessprice hastings
//mindownloadbandwidthprice hastings/byte
//minstorageprice hastings/byte/block
//minuploadbandwidthprice hastings/byte
//maxephemeralaccountbalance hastings
//maxephemeralaccountrisk hastings
//registrysize int
//customregistrypath string
return siacPostDataCommand('host'+optsString,'');
/*
siacPostDataCommand('wallet/siacoins',`amount=${amountHastings}&destination=${destination}`).then(d=>{
console.log('sent coins',d);
}).catch(e=>{
console.error('ERROR SENDING COIN',e);
});
*/
}
announceHost(netaddress){
console.log('announce address',netaddress);
return siacPostDataCommand(`host/announce?netaddress=${netaddress}`,'')
//return siacCommand('host/announce','POST');
/*.then(d=>{
console.log('host announced stats',d);
}).catch(e=>{
console.error('ERROR SETTING HOST ANNOUNCEMENT INFO',e);
});*/
}
getContracts(){
return siacCommand('host/contracts','GET');/*.then(d=>{
console.log('host contracts stats',d);
}).catch(e=>{
console.error('ERROR GETTING HOST CONTRACTS INFO',e);
});*/
}
getContract(id){
return siacCommand(`host/contracts/${id}`,'GET');/*.then(d=>{
console.log('host contract stats',d);
}).catch(e=>{
console.error('ERROR GETTING HOST CONTRACT INFO',e);
});*/
}
getStorage(){
return siacCommand('host/storage','GET');/*.then(d=>{
console.log('host storage stats',d);
}).catch(e=>{
console.error('ERROR GETTING HOST STORAGE INFO',e);
});*/
}
addStorageFolder(path,size){
//size = bytes
return siacPostDataCommand('host/storage/folders/add',`path=${path}&size=${size}`);/*.then(d=>{
console.log('added storage folder',d);
}).catch(e=>{
console.error('ERROR ADDING STORAGE FOLDER',e);
});*/
}
removeStorageFolder(path,forceRemove){
return siacPostDataCommand('host/storage/folders/remove',`path=${path}&force=${forceRemove}`);/*.then(d=>{
console.log('added storage folder',d);
}).catch(e=>{
console.error('ERROR ADDING STORAGE FOLDER',e);
});*/
}
resizeStorageFolder(path,size){
//size = bytes
return siacPostDataCommand('host/storage/folders/resize',`path=${path}&newsize=${size}`);/*.then(d=>{
console.log('resized storage folder',d);
}).catch(e=>{
console.error('ERROR RESIZING STORAGE FOLDER',e);
});*/
}
deleteSector(merkleRoot){
///host/storage/sectors/delete/:merkleroot
siacCommand(`host/storage/sectors/delete/${merkleRoot}`,'POST').then(d=>{
console.log('host removed sector by merkle root stats',d);
}).catch(e=>{
console.error('ERROR DELETING SECTOR BY MERKLE INFO',e);
});
}
estimateScore(){
return siacCommand('host/estimatescore','GET');/*.then(d=>{
console.log('est. host score stats',d);
}).catch(e=>{
console.error('ERROR GETTING EST HOST SCORE INFO',e);
});*/
}
}