aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-07-07 16:57:28 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-07-07 18:23:18 +0200
commit709756b8e183f67ef9bf8f7bc149af4736260350 (patch)
treedc5e52878a6f56c69a4589e058e830c57b025a05 /server/lib
parent18c8e945089bff49d2c617c411c8a8f4575989ad (diff)
downloadPeerTube-709756b8e183f67ef9bf8f7bc149af4736260350.tar.gz
PeerTube-709756b8e183f67ef9bf8f7bc149af4736260350.tar.zst
PeerTube-709756b8e183f67ef9bf8f7bc149af4736260350.zip
Async signature and various fixes
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/friends.ts6
-rw-r--r--server/lib/request/abstract-request-scheduler.ts1
-rw-r--r--server/lib/request/request-scheduler.ts9
3 files changed, 3 insertions, 13 deletions
diff --git a/server/lib/friends.ts b/server/lib/friends.ts
index 498144318..c24839cb6 100644
--- a/server/lib/friends.ts
+++ b/server/lib/friends.ts
@@ -141,9 +141,7 @@ function makeFriends (hosts: string[]) {
141 logger.info('Make friends!') 141 logger.info('Make friends!')
142 return getMyPublicCert() 142 return getMyPublicCert()
143 .then(cert => { 143 .then(cert => {
144 return Promise.mapSeries(hosts, host => { 144 return Promise.each(hosts, host => computeForeignPodsList(host, podsScore)).then(() => cert)
145 return computeForeignPodsList(host, podsScore)
146 }).then(() => cert)
147 }) 145 })
148 .then(cert => { 146 .then(cert => {
149 logger.debug('Pods scores computed.', { podsScore: podsScore }) 147 logger.debug('Pods scores computed.', { podsScore: podsScore })
@@ -169,7 +167,6 @@ function quitFriends () {
169 const requestParams = { 167 const requestParams = {
170 method: 'POST' as 'POST', 168 method: 'POST' as 'POST',
171 path: '/api/' + API_VERSION + '/remote/pods/remove', 169 path: '/api/' + API_VERSION + '/remote/pods/remove',
172 sign: true,
173 toPod: null 170 toPod: null
174 } 171 }
175 172
@@ -178,6 +175,7 @@ function quitFriends () {
178 // The other pod will exclude us automatically after a while 175 // The other pod will exclude us automatically after a while
179 return Promise.map(pods, pod => { 176 return Promise.map(pods, pod => {
180 requestParams.toPod = pod 177 requestParams.toPod = pod
178
181 return makeSecureRequest(requestParams) 179 return makeSecureRequest(requestParams)
182 }, { concurrency: REQUESTS_IN_PARALLEL }) 180 }, { concurrency: REQUESTS_IN_PARALLEL })
183 .then(() => pods) 181 .then(() => pods)
diff --git a/server/lib/request/abstract-request-scheduler.ts b/server/lib/request/abstract-request-scheduler.ts
index dd77fddb7..128fc5b28 100644
--- a/server/lib/request/abstract-request-scheduler.ts
+++ b/server/lib/request/abstract-request-scheduler.ts
@@ -70,7 +70,6 @@ abstract class AbstractRequestScheduler <T> {
70 protected makeRequest (toPod: PodInstance, requestEndpoint: string, requestsToMake: Object) { 70 protected makeRequest (toPod: PodInstance, requestEndpoint: string, requestsToMake: Object) {
71 const params = { 71 const params = {
72 toPod: toPod, 72 toPod: toPod,
73 sign: true, // Prove our identity
74 method: 'POST' as 'POST', 73 method: 'POST' as 'POST',
75 path: '/api/' + API_VERSION + '/remote/' + requestEndpoint, 74 path: '/api/' + API_VERSION + '/remote/' + requestEndpoint,
76 data: requestsToMake // Requests we need to make 75 data: requestsToMake // Requests we need to make
diff --git a/server/lib/request/request-scheduler.ts b/server/lib/request/request-scheduler.ts
index 0dd796fb0..8927d53bb 100644
--- a/server/lib/request/request-scheduler.ts
+++ b/server/lib/request/request-scheduler.ts
@@ -61,16 +61,9 @@ class RequestScheduler extends AbstractRequestScheduler<RequestsGrouped> {
61 } 61 }
62 62
63 createRequest ({ type, endpoint, data, toIds, transaction }: RequestSchedulerOptions) { 63 createRequest ({ type, endpoint, data, toIds, transaction }: RequestSchedulerOptions) {
64 // TODO: check the setPods works
65 const podIds = []
66
67 // If there are no destination pods abort 64 // If there are no destination pods abort
68 if (toIds.length === 0) return undefined 65 if (toIds.length === 0) return undefined
69 66
70 toIds.forEach(toPod => {
71 podIds.push(toPod)
72 })
73
74 const createQuery = { 67 const createQuery = {
75 endpoint, 68 endpoint,
76 request: { 69 request: {
@@ -85,7 +78,7 @@ class RequestScheduler extends AbstractRequestScheduler<RequestsGrouped> {
85 78
86 return db.Request.create(createQuery, dbRequestOptions) 79 return db.Request.create(createQuery, dbRequestOptions)
87 .then(request => { 80 .then(request => {
88 return request.setPods(podIds, dbRequestOptions) 81 return request.setPods(toIds, dbRequestOptions)
89 }) 82 })
90 } 83 }
91 84