Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
2a010ad9
Unverified
Commit
2a010ad9
authored
Sep 23, 2019
by
yann300
Committed by
GitHub
Sep 23, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2359 from ethereum/pushes_on_several_ipfs_gateways
Push on several ipfs nodes
parents
071d7452
c8dca0eb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
publishOnIpfs.js
src/lib/publishOnIpfs.js
+12
-3
No files found.
src/lib/publishOnIpfs.js
View file @
2a010ad9
...
...
@@ -2,8 +2,11 @@
const
async
=
require
(
'async'
)
const
IpfsClient
=
require
(
'ipfs-mini'
)
const
host
=
'ipfs.komputing.org'
const
ipfs
=
new
IpfsClient
({
host
,
port
:
443
,
protocol
:
'https'
})
const
ipfsNodes
=
[
new
IpfsClient
({
host
:
'ipfs.komputing.org'
,
port
:
443
,
protocol
:
'https'
}),
new
IpfsClient
({
host
:
'ipfs.infura.io'
,
port
:
5001
,
protocol
:
'https'
})
]
module
.
exports
=
(
contract
,
fileManager
,
cb
,
ipfsVerifiedPublishCallBack
)
=>
{
// gather list of files to publish
...
...
@@ -89,7 +92,7 @@ module.exports = (contract, fileManager, cb, ipfsVerifiedPublishCallBack) => {
async
function
ipfsVerifiedPublish
(
content
,
expectedHash
,
cb
)
{
try
{
const
results
=
await
ipfs
.
add
(
content
)
const
results
=
await
severalGatewaysPush
(
content
)
if
(
results
!==
expectedHash
)
{
cb
(
null
,
{
message
:
'hash mismatch between solidity bytecode and uploaded content.'
,
url
:
'dweb:/ipfs/'
+
results
,
hash
:
results
})
}
else
{
...
...
@@ -99,3 +102,9 @@ async function ipfsVerifiedPublish (content, expectedHash, cb) {
cb
(
error
)
}
}
function
severalGatewaysPush
(
content
)
{
const
invert
=
p
=>
new
Promise
((
resolve
,
reject
)
=>
p
.
then
(
reject
).
catch
(
resolve
))
// Invert res and rej
const
promises
=
ipfsNodes
.
map
((
node
)
=>
invert
(
node
.
add
(
content
)))
return
invert
(
Promise
.
all
(
promises
))
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment