Skip to content

Commit e0c95b7

Browse files
dwasylukdwasyluk
authored andcommitted
Merge branch 'dev-1.1.4'
2 parents 8c328ed + 2f58240 commit e0c95b7

6 files changed

Lines changed: 2 additions & 273 deletions

File tree

server/nodejs/api/swagger.yaml

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -48,33 +48,6 @@ paths:
4848
$ref: "#/definitions/ErrorResponse"
4949
x-swagger-router-controller: "Blockmarket"
5050
x-swagger-router-controller: "blockmarket"
51-
/storedata:
52-
post:
53-
tags:
54-
- "Blockmarket"
55-
description: "Store an arbitrary piece of data on a decentralized network of\
56-
\ data storage warehouses and return the client an array of URLs through which\
57-
\ the data can be accessed."
58-
operationId: "storedata"
59-
parameters:
60-
- in: "body"
61-
name: "request"
62-
required: true
63-
schema:
64-
$ref: "#/definitions/StoreDataRequest"
65-
responses:
66-
200:
67-
description: "Success"
68-
schema:
69-
$ref: "#/definitions/StoreDataResponse"
70-
default:
71-
description: "Error"
72-
schema:
73-
$ref: "#/definitions/ErrorResponse"
74-
security:
75-
- token: []
76-
x-swagger-router-controller: "Blockmarket"
77-
x-swagger-router-controller: "blockmarket"
7851
/getblock:
7952
get:
8053
tags:
@@ -5281,48 +5254,6 @@ definitions:
52815254
type: "string"
52825255
description: "The pass phrase to encrypt the wallet with. It must be at least\
52835256
\ 1 character, but should be long."
5284-
StoreDataRequest:
5285-
required:
5286-
- "data"
5287-
- "dataType"
5288-
properties:
5289-
existingDataId:
5290-
type: "string"
5291-
description: "Identifier for existing data to update."
5292-
dataType:
5293-
type: "string"
5294-
description: "The type of data being stored, ie: 'aliasdata'."
5295-
data:
5296-
type: "string"
5297-
description: "The data to be stored on the decentralized storage facility.\
5298-
\ Max size 500kb."
5299-
storeLocations:
5300-
type: "array"
5301-
description: "Array of data warehousing facilities to use to store the data,\
5302-
\ valid values: BFAZURE."
5303-
items:
5304-
type: "string"
5305-
StoreDataResponse:
5306-
required:
5307-
- "storeLocations"
5308-
properties:
5309-
storeLocations:
5310-
type: "array"
5311-
description: "Array of objects which describe where data is stored offchain"
5312-
items:
5313-
$ref: "#/definitions/DataStoreLocation"
5314-
example:
5315-
storeLocations:
5316-
- dataUrl: "aeiou"
5317-
DataStoreLocation:
5318-
required:
5319-
- "dataUrl"
5320-
properties:
5321-
dataUrl:
5322-
type: "string"
5323-
description: "URL from which the data can be fetched"
5324-
example:
5325-
dataUrl: "aeiou"
53265257
NetworkInfo:
53275258
properties:
53285259
version:

server/nodejs/controllers/Blockmarket.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,3 @@ module.exports.login = function login (req, res, next) {
1010
Blockmarket.login(req.swagger.params, res, next);
1111
};
1212

13-
module.exports.storedata = function storedata (req, res, next) {
14-
Blockmarket.storedata(req.swagger.params, res, next);
15-
};

server/nodejs/controllers/BlockmarketService.js

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -41,56 +41,4 @@ exports.login = function(args, res, next) {
4141
token: token
4242
}));
4343
}
44-
}
45-
46-
exports.storedata = async (args, res, next) => {
47-
const existingDataId = args.request.value.existingDataId;
48-
const dataType = "aliasdata"; //args.request.value.dataType;
49-
const data = args.request.value.data;
50-
res.setHeader('Content-Type', 'application/json');
51-
52-
try {
53-
const db = await MongoClient.connect(config.mongodb.database_url);
54-
const collection = db.collection("aliasdata"); //TODO: change collectionName to variable
55-
console.log("storing data offchain: " + data);
56-
57-
let filter;
58-
const newId = new ObjectID();
59-
if(existingDataId) {
60-
try {
61-
filter = {_id: ObjectID(existingDataId), dataType: dataType};
62-
let docs = await collection.find(filter).toArray();
63-
if(docs.length > 1) {
64-
res.writeHead(500);
65-
res.end(JSON.stringify({ success: false, message: `Data id ${existingDataId} returned ${docs.length} matches, too many!` }));
66-
}else if(docs.length == 0) {
67-
console.log("No matches found for provided ID, creating new ID.");
68-
filter._id = newId;
69-
}
70-
}catch(e) { //objectid error, create new id
71-
console.log("Object ID error create new ID.");
72-
filter = { _id: newId, dataType: dataType};
73-
}
74-
} else {
75-
filter = { _id: newId, dataType: dataType};
76-
}
77-
78-
try {
79-
const result = await mongoUtils.upsertDocument(collection, filter, { dataType: 'aliasdata', data: data });
80-
let ret = {
81-
storeLocations: [
82-
{ dataUrl: config.mongodb.offchain_url + result.upsertedId }
83-
]
84-
};
85-
res.end(JSON.stringify(ret));
86-
}catch(err) {
87-
res.writeHead(500);
88-
res.end(JSON.stringify({ success: false, message: 'Error inserting data into offchain data storage service. Details: ' + JSON.stringify(err) }));
89-
}
90-
}catch(err) {
91-
res.writeHead(500);
92-
res.end(JSON.stringify({ success: false, message: 'Error connecting from API to data storage service. Details: ' + JSON.stringify(err) }));
93-
}
94-
}
95-
;
96-
44+
};

swagger-ui

swagger.yaml

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -53,32 +53,6 @@ paths:
5353
schema:
5454
$ref: "#/definitions/ErrorResponse"
5555

56-
/storedata:
57-
x-swagger-router-controller: blockmarket
58-
post:
59-
operationId: storedata
60-
description: "Store an arbitrary piece of data on a decentralized network of data storage warehouses and return the client \
61-
an array of URLs through which the data can be accessed."
62-
security:
63-
- token: []
64-
tags:
65-
- Blockmarket
66-
parameters:
67-
- name: request
68-
in: body
69-
required: true
70-
schema:
71-
$ref: "#/definitions/StoreDataRequest"
72-
responses:
73-
"200":
74-
description: Success
75-
schema:
76-
$ref: "#/definitions/StoreDataResponse"
77-
default:
78-
description: Error
79-
schema:
80-
$ref: "#/definitions/ErrorResponse"
81-
8256
/getblock:
8357
x-swagger-router-controller: rpc
8458
get:
@@ -4728,41 +4702,6 @@ definitions:
47284702
passphrase:
47294703
type: string
47304704
description: The pass phrase to encrypt the wallet with. It must be at least 1 character, but should be long.
4731-
StoreDataRequest:
4732-
required:
4733-
- data
4734-
- dataType
4735-
properties:
4736-
existingDataId:
4737-
type: string
4738-
description: Identifier for existing data to update.
4739-
dataType:
4740-
type: string
4741-
description: "The type of data being stored, ie: 'aliasdata'."
4742-
data:
4743-
type: string
4744-
description: The data to be stored on the decentralized storage facility. Max size 500kb.
4745-
storeLocations:
4746-
description: "Array of data warehousing facilities to use to store the data, valid values: BFAZURE."
4747-
type: array
4748-
items:
4749-
type: string
4750-
StoreDataResponse:
4751-
required:
4752-
- storeLocations
4753-
properties:
4754-
storeLocations:
4755-
type: array
4756-
items:
4757-
$ref: "#/definitions/DataStoreLocation"
4758-
description: Array of objects which describe where data is stored offchain
4759-
DataStoreLocation:
4760-
required:
4761-
- dataUrl
4762-
properties:
4763-
dataUrl:
4764-
type: string
4765-
description: URL from which the data can be fetched
47664705
NetworkInfo:
47674706
properties:
47684707
version:

swagger_generated.json

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -57,39 +57,6 @@
5757
},
5858
"x-swagger-router-controller" : "blockmarket"
5959
},
60-
"/storedata" : {
61-
"post" : {
62-
"tags" : [ "Blockmarket" ],
63-
"description" : "Store an arbitrary piece of data on a decentralized network of data storage warehouses and return the client an array of URLs through which the data can be accessed.",
64-
"operationId" : "storedata",
65-
"parameters" : [ {
66-
"in" : "body",
67-
"name" : "request",
68-
"required" : true,
69-
"schema" : {
70-
"$ref" : "#/definitions/StoreDataRequest"
71-
}
72-
} ],
73-
"responses" : {
74-
"200" : {
75-
"description" : "Success",
76-
"schema" : {
77-
"$ref" : "#/definitions/StoreDataResponse"
78-
}
79-
},
80-
"default" : {
81-
"description" : "Error",
82-
"schema" : {
83-
"$ref" : "#/definitions/ErrorResponse"
84-
}
85-
}
86-
},
87-
"security" : [ {
88-
"token" : [ ]
89-
} ]
90-
},
91-
"x-swagger-router-controller" : "blockmarket"
92-
},
9360
"/getblock" : {
9461
"get" : {
9562
"tags" : [ "General" ],
@@ -6450,59 +6417,6 @@
64506417
}
64516418
}
64526419
},
6453-
"StoreDataRequest" : {
6454-
"required" : [ "data", "dataType" ],
6455-
"properties" : {
6456-
"existingDataId" : {
6457-
"type" : "string",
6458-
"description" : "Identifier for existing data to update."
6459-
},
6460-
"dataType" : {
6461-
"type" : "string",
6462-
"description" : "The type of data being stored, ie: 'aliasdata'."
6463-
},
6464-
"data" : {
6465-
"type" : "string",
6466-
"description" : "The data to be stored on the decentralized storage facility. Max size 500kb."
6467-
},
6468-
"storeLocations" : {
6469-
"type" : "array",
6470-
"description" : "Array of data warehousing facilities to use to store the data, valid values: BFAZURE.",
6471-
"items" : {
6472-
"type" : "string"
6473-
}
6474-
}
6475-
}
6476-
},
6477-
"StoreDataResponse" : {
6478-
"required" : [ "storeLocations" ],
6479-
"properties" : {
6480-
"storeLocations" : {
6481-
"type" : "array",
6482-
"description" : "Array of objects which describe where data is stored offchain",
6483-
"items" : {
6484-
"$ref" : "#/definitions/DataStoreLocation"
6485-
}
6486-
}
6487-
},
6488-
"example" : {
6489-
"storeLocations" : [ {
6490-
"dataUrl" : "aeiou"
6491-
} ]
6492-
}
6493-
},
6494-
"DataStoreLocation" : {
6495-
"required" : [ "dataUrl" ],
6496-
"properties" : {
6497-
"dataUrl" : {
6498-
"type" : "string",
6499-
"description" : "URL from which the data can be fetched"
6500-
}
6501-
},
6502-
"example" : {
6503-
"dataUrl" : "aeiou"
6504-
}
6505-
},
65066420
"NetworkInfo" : {
65076421
"properties" : {
65086422
"version" : {

0 commit comments

Comments
 (0)