File size: 1,729 Bytes
55c2187
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.0;

contract DataStore {
struct Dataset {
string name;
string ipfshash;
uint voterCount;
}

struct Model {
    string name;
    string ipfshash;
    uint voterCount;
}

struct Paper {
    string name;
    string ipfshash;
    uint voterCount;
}

mapping(string => Dataset) datasets;
mapping(string => Model) models;
mapping(string => Paper) papers;

function storeDataset(string memory _name, string memory _ipfshash) public {
    require(datasets[_name].voterCount > 1, "Voter count not met.");
    datasets[_name] = Dataset(_name, _ipfshash, 0);
}

function storeModel(string memory _name, string memory _ipfshash) public {
    require(models[_name].voterCount > 1, "Voter count not met.");
    models[_name] = Model(_name, _ipfshash, 0);
}

function storePaper(string memory _name, string memory _ipfshash) public {
    require(papers[_name].voterCount > 1, "Voter count not met.");
    papers[_name] = Paper(_name, _ipfshash, 0);
}

function retrieveDataset(string memory _name) public view returns (string memory, string memory) {
    return (datasets[_name].name, datasets[_name].ipfshash);
}

function retrieveModel(string memory _name) public view returns (string memory, string memory) {
    return (models[_name].name, models[_name].ipfshash);
}

function retrievePaper(string memory _name) public view returns (string memory, string memory) {
    return (papers[_name].name, papers[_name].ipfshash);
}

function voteDataset(string memory _name) public {
    datasets[_name].voterCount++;
}

function voteModel(string memory _name) public {
    models[_name].voterCount++;
}

function votePaper(string memory _name) public {
    papers[_name].voterCount++;
}
}