Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contracts/CptController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ contract CptController {
intArray[0] = cptVersion;
int created = cptIntArray[1];
intArray[1] = created;
cptData.putCpt(cptId, publisher, intArray, bytes32Array, jsonSchemaArray, v, r, s);
cptData.updateCpt(cptId, publisher, intArray, bytes32Array, jsonSchemaArray, v, r, s);
UpdateCptRetLog(0, cptId, cptVersion);
return true;
} else {
Expand Down
135 changes: 121 additions & 14 deletions contracts/CptData.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ contract CptData {
uint constant public NONE_AUTHORITY_ISSUER_START_ID = 2000000;
uint private authority_issuer_current_id = 1000;
uint private none_authority_issuer_current_id = 2000000;


// Default CPT version
uint constant private CPT_DEFAULT_VERSION = 1;

AuthorityIssuerData private authorityIssuerData;

function CptData(
Expand Down Expand Up @@ -56,8 +59,9 @@ contract CptData {
//store signature
Signature signature;
}

mapping (uint => Cpt) private cptMap;

mapping (uint => mapping(uint => Cpt)) private cptMap;

uint[] private cptIdList;

function putCpt(
Expand All @@ -74,11 +78,29 @@ contract CptData {
returns (bool)
{
Signature memory cptSignature = Signature({v: cptV, r: cptR, s: cptS});
cptMap[cptId] = Cpt({publisher: cptPublisher, intArray: cptIntArray, bytes32Array: cptBytes32Array, jsonSchemaArray:cptJsonSchemaArray, signature: cptSignature});
cptMap[cptId][uint(cptIntArray[0])] = Cpt({publisher: cptPublisher, intArray: cptIntArray, bytes32Array: cptBytes32Array, jsonSchemaArray:cptJsonSchemaArray, signature: cptSignature});
cptIdList.push(cptId);
return true;
}

function updateCpt(
uint cptId,
address cptPublisher,
int[8] cptIntArray,
bytes32[8] cptBytes32Array,
bytes32[128] cptJsonSchemaArray,
uint8 cptV,
bytes32 cptR,
bytes32 cptS
)
public
returns (bool)
{
Signature memory cptSignature = Signature({v: cptV, r: cptR, s: cptS});
cptMap[cptId][uint(cptIntArray[0])] = Cpt({publisher: cptPublisher, intArray: cptIntArray, bytes32Array: cptBytes32Array, jsonSchemaArray:cptJsonSchemaArray, signature: cptSignature});
return true;
}

function getCptId(
address publisher
)
Expand Down Expand Up @@ -117,7 +139,32 @@ contract CptData {
bytes32 r,
bytes32 s)
{
Cpt memory cpt = cptMap[cptId];
Cpt memory cpt = cptMap[cptId][CPT_DEFAULT_VERSION];
publisher = cpt.publisher;
intArray = cpt.intArray;
bytes32Array = cpt.bytes32Array;
jsonSchemaArray = cpt.jsonSchemaArray;
v = cpt.signature.v;
r = cpt.signature.r;
s = cpt.signature.s;
}

function getCpt(
uint cptId,
uint version
)
public
constant
returns (
address publisher,
int[8] intArray,
bytes32[8] bytes32Array,
bytes32[128] jsonSchemaArray,
uint8 v,
bytes32 r,
bytes32 s)
{
Cpt memory cpt = cptMap[cptId][version];
publisher = cpt.publisher;
intArray = cpt.intArray;
bytes32Array = cpt.bytes32Array;
Expand All @@ -126,37 +173,72 @@ contract CptData {
r = cpt.signature.r;
s = cpt.signature.s;
}

function getCptPublisher(
uint cptId
)
public
constant
returns (address publisher)
{
Cpt memory cpt = cptMap[cptId];
Cpt memory cpt = cptMap[cptId][CPT_DEFAULT_VERSION];
publisher = cpt.publisher;
}

function getCptPublisher(
uint cptId,
uint version
)
public
constant
returns (address publisher)
{
Cpt memory cpt = cptMap[cptId][version];
publisher = cpt.publisher;
}

function getCptIntArray(
uint cptId
)
public
constant
returns (int[8] intArray)
{
Cpt memory cpt = cptMap[cptId];
Cpt memory cpt = cptMap[cptId][CPT_DEFAULT_VERSION];
intArray = cpt.intArray;
}


function getCptIntArray(
uint cptId,
uint version
)
public
constant
returns (int[8] intArray)
{
Cpt memory cpt = cptMap[cptId][version];
intArray = cpt.intArray;
}

function getCptJsonSchemaArray(
uint cptId
)
public
constant
returns (bytes32[128] jsonSchemaArray)
{
Cpt memory cpt = cptMap[cptId];
Cpt memory cpt = cptMap[cptId][CPT_DEFAULT_VERSION];
jsonSchemaArray = cpt.jsonSchemaArray;
}

function getCptJsonSchemaArray(
uint cptId,
uint version
)
public
constant
returns (bytes32[128] jsonSchemaArray)
{
Cpt memory cpt = cptMap[cptId][version];
jsonSchemaArray = cpt.jsonSchemaArray;
}

Expand All @@ -167,7 +249,19 @@ contract CptData {
constant
returns (bytes32[8] bytes32Array)
{
Cpt memory cpt = cptMap[cptId];
Cpt memory cpt = cptMap[cptId][CPT_DEFAULT_VERSION];
bytes32Array = cpt.bytes32Array;
}

function getCptBytes32Array(
uint cptId,
uint version
)
public
constant
returns (bytes32[8] bytes32Array)
{
Cpt memory cpt = cptMap[cptId][version];
bytes32Array = cpt.bytes32Array;
}

Expand All @@ -178,12 +272,25 @@ contract CptData {
constant
returns (uint8 v, bytes32 r, bytes32 s)
{
Cpt memory cpt = cptMap[cptId];
Cpt memory cpt = cptMap[cptId][CPT_DEFAULT_VERSION];
v = cpt.signature.v;
r = cpt.signature.r;
s = cpt.signature.s;
}

function getCptSignature(
uint cptId,
uint version
)
public
constant
returns (uint8 v, bytes32 r, bytes32 s)
{
Cpt memory cpt = cptMap[cptId][version];
v = cpt.signature.v;
r = cpt.signature.r;
s = cpt.signature.s;
}

function isCptExist(
uint cptId
)
Expand Down