Add node ID field to file structure

This commit is contained in:
Kleissner
2021-09-28 19:55:30 +02:00
parent 608dbf6f47
commit 2c20fa950d
6 changed files with 22 additions and 10 deletions

View File

@@ -106,7 +106,8 @@ type apiBlockRecordFile struct {
Folder string `json:"folder"` // Folder, optional
Name string `json:"name"` // Name of the file
Description string `json:"description"` // Description. This is expected to be multiline and contain hashtags!
Date time.Time `json:"date"` // Date of the virtual file
Date time.Time `json:"date"` // Date shared
NodeID []byte `json:"nodeid"` // Node ID, owner of the file
Metadata []apiFileMetadata `json:"metadata"` // Additional metadata.
}
@@ -228,7 +229,7 @@ func apiBlockchainSelfDeleteFile(w http.ResponseWriter, r *http.Request) {
// --- conversion from core to API data ---
func blockRecordFileToAPI(input core.BlockRecordFile) (output apiBlockRecordFile) {
output = apiBlockRecordFile{ID: input.ID, Hash: input.Hash, Type: input.Type, Format: input.Format, Size: input.Size, Metadata: []apiFileMetadata{}}
output = apiBlockRecordFile{ID: input.ID, Hash: input.Hash, NodeID: input.NodeID, Type: input.Type, Format: input.Format, Size: input.Size, Metadata: []apiFileMetadata{}}
for _, tag := range input.Tags {
switch tag.Type {

View File

@@ -159,6 +159,9 @@ func createTestResult(fileType int) (file core.BlockRecordFile) {
file.ID = uuid.New()
file.Size = uint64(len(randomData))
file.NodeID = make([]byte, 32) // node ID = blake3 hash of peer ID
rand.Read(file.NodeID)
if fileType == -1 {
switch file.Format {
case core.FormatCSV, core.FormatEmail, core.FormatText, core.FormatHTML:

View File

@@ -181,7 +181,7 @@ The array `RecordsDecoded` will contain any present record of the following:
## File Functions
These functions allow adding, deleting, and listing files stored on the users blockchain. Only metadata is actually stored on the blockchain.
These functions allow adding, deleting, and listing files stored on the users blockchain. Only metadata is actually stored on the blockchain. To download a remote file both the file hash and the node ID are required. The node ID specifies the owner of the file.
```go
type apiBlockRecordFile struct {
@@ -193,7 +193,8 @@ type apiBlockRecordFile struct {
Folder string `json:"folder"` // Folder, optional
Name string `json:"name"` // Name of the file
Description string `json:"description"` // Description. This is expected to be multiline and contain hashtags!
Date time.Time `json:"date"` // Date of the virtual file
Date time.Time `json:"date"` // Date shared
NodeID []byte `json:"nodeid"` // Node ID, owner of the file
Metadata []apiFileMetadata `json:"metadata"` // Additional metadata.
}
@@ -296,6 +297,7 @@ Example response:
"name": "Test.txt",
"description": "",
"date": "2021-08-27T14:59:13Z",
"nodeid": "0Zo9QHCF06Nrbxgg9s4Q4wYpcHzsQhSMsmftQqjanVI=",
"metadata": []
}, {
"id": "bc32cbae-011d-4f0b-80a8-281ca9369211",
@@ -307,6 +309,7 @@ Example response:
"name": "Test 2.txt",
"description": "Example description\nThis can be any text #newfile #2021.",
"date": "2021-09-27T23:33:37Z",
"nodeid": "0Zo9QHCF06Nrbxgg9s4Q4wYpcHzsQhSMsmftQqjanVI=",
"metadata": [{
"type": 2,
"name": "Date Created",
@@ -566,6 +569,7 @@ Example response with dummy data:
"name": "88d8cc57d5c2a5fea881ceea09503ee4.txt",
"description": "",
"date": "2021-09-23T00:00:00Z",
"nodeid": "j4yHzmCXiXqg4DPhowj0DIOuuyJxQflo2QSNG3yhCK8=",
"metadata": []
}]
}