mirror of
https://github.com/PeernetOfficial/core.git
synced 2026-07-21 04:17:50 +01:00
New features (#110)
* added upload status * added changes for progress bar with more logs and bug fixes, Documentation yet to be added * huge changes that need more doucmenting * added possibility to get profile using NodeID * added fix profile listing user profile information * removed profile image from the explore reult struct * saving current changes * added filter to search based on NodeID * Monday bug fixing * updates to the profile * changes for tracing the blockchain profile image not shown * added condition to ensure TAG is not sent and removed debug prints * updated webapi docs
This commit is contained in:
committed by
GitHub
parent
97c3001596
commit
ae5f1d2fd7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
File Name: Block Record File.go
|
||||
File Username: Block Record File.go
|
||||
Copyright: 2021 Peernet s.r.o.
|
||||
Author: Peter Kleissner
|
||||
|
||||
@@ -48,6 +48,7 @@ type BlockRecordFile struct {
|
||||
Size uint64 // Size of the file data
|
||||
NodeID []byte // Node ID, owner of the file
|
||||
Tags []BlockRecordFileTag // Tags provide additional metadata
|
||||
Username string // Username of the User who uploaded the file
|
||||
}
|
||||
|
||||
// BlockRecordFileTag provides metadata about the file.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
File Name: Block Record Profile.go
|
||||
File Username: Block Record Profile.go
|
||||
Copyright: 2021 Peernet s.r.o.
|
||||
Author: Peter Kleissner
|
||||
|
||||
@@ -24,8 +24,8 @@ type BlockRecordProfile struct {
|
||||
Data []byte // Data
|
||||
}
|
||||
|
||||
// decodeBlockRecordProfile decodes only profile records. Other records are ignored.
|
||||
func decodeBlockRecordProfile(recordsRaw []BlockRecordRaw) (fields []BlockRecordProfile, err error) {
|
||||
// DecodeBlockRecordProfile decodes only profile records. Other records are ignored.
|
||||
func DecodeBlockRecordProfile(recordsRaw []BlockRecordRaw) (fields []BlockRecordProfile, err error) {
|
||||
fieldMap := make(map[uint16][]byte)
|
||||
|
||||
for _, record := range recordsRaw {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
File Name: Block Record.go
|
||||
File Username: Block Record.go
|
||||
Copyright: 2021 Peernet s.r.o.
|
||||
Author: Peter Kleissner
|
||||
|
||||
@@ -45,7 +45,7 @@ func decodeBlockRecords(block *Block) (decoded *BlockDecoded, err error) {
|
||||
decoded.RecordsDecoded = append(decoded.RecordsDecoded, file)
|
||||
}
|
||||
|
||||
if profileFields, err := decodeBlockRecordProfile(block.RecordsRaw); err != nil {
|
||||
if profileFields, err := DecodeBlockRecordProfile(block.RecordsRaw); err != nil {
|
||||
return nil, err
|
||||
} else if len(profileFields) > 0 {
|
||||
decoded.RecordsDecoded = append(decoded.RecordsDecoded, profileFields)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
File Name: Block.go
|
||||
File Username: Block.go
|
||||
Copyright: 2021 Peernet s.r.o.
|
||||
Author: Peter Kleissner
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
File Name: Blockchain.go
|
||||
File Username: Blockchain.go
|
||||
Copyright: 2021 Peernet s.r.o.
|
||||
Author: Peter Kleissner
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
File Name: File Tag.go
|
||||
File Username: File Tag.go
|
||||
Copyright: 2021 Peernet s.r.o.
|
||||
Author: Peter Kleissner
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
|
||||
// List of defined file tags. Virtual tags are generated at runtime and are read-only. They cannot be stored on the blockchain.
|
||||
const (
|
||||
TagName = 0 // Name of file.
|
||||
TagName = 0 // Username of file.
|
||||
TagFolder = 1 // Folder name.
|
||||
TagDescription = 2 // Arbitrary description of the file. May contain hashtags.
|
||||
TagDateShared = 3 // When the file was published on the blockchain. Virtual.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
File Name: File.go
|
||||
File Username: File.go
|
||||
Copyright: 2021 Peernet s.r.o.
|
||||
Author: Peter Kleissner
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
File Name: Multi.go
|
||||
File Username: Multi.go
|
||||
Copyright: 2021 Peernet s.r.o.
|
||||
Author: Peter Kleissner
|
||||
|
||||
@@ -16,6 +16,7 @@ package blockchain
|
||||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/PeernetOfficial/core/btcec"
|
||||
@@ -277,7 +278,11 @@ func (multi *MultiStore) IngestBlock(header *MultiBlockchainHeader, blockNumber
|
||||
}
|
||||
|
||||
// store the transferred block in the cache
|
||||
multi.WriteBlock(header.PublicKey, header.Version, blockNumber, raw)
|
||||
err = multi.WriteBlock(header.PublicKey, header.Version, blockNumber, raw)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
header.ListBlocks = append(header.ListBlocks, blockNumber)
|
||||
|
||||
// update blockchain header stats if records were decoded
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
File Name: Profile Data.go
|
||||
File Username: Profile Data.go
|
||||
Copyright: 2021 Peernet s.r.o.
|
||||
Author: Peter Kleissner
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
File Name: Profile.go
|
||||
File Username: Profile.go
|
||||
Copyright: 2021 Peernet s.r.o.
|
||||
Author: Peter Kleissner
|
||||
*/
|
||||
@@ -11,7 +11,7 @@ func (blockchain *Blockchain) ProfileReadField(index uint16) (data []byte, statu
|
||||
found := false
|
||||
|
||||
status = blockchain.Iterate(func(block *Block) (statusI int) {
|
||||
fields, err := decodeBlockRecordProfile(block.RecordsRaw)
|
||||
fields, err := DecodeBlockRecordProfile(block.RecordsRaw)
|
||||
if err != nil {
|
||||
return StatusCorruptBlockRecord
|
||||
} else if len(fields) == 0 {
|
||||
@@ -43,7 +43,7 @@ func (blockchain *Blockchain) ProfileList() (fields []BlockRecordProfile, status
|
||||
uniqueFields := make(map[uint16][]byte)
|
||||
|
||||
status = blockchain.Iterate(func(block *Block) (statusI int) {
|
||||
fields, err := decodeBlockRecordProfile(block.RecordsRaw)
|
||||
fields, err := DecodeBlockRecordProfile(block.RecordsRaw)
|
||||
if err != nil {
|
||||
return StatusCorruptBlockRecord
|
||||
}
|
||||
@@ -103,7 +103,7 @@ func (blockchain *Blockchain) ProfileDelete(fields []uint16) (newHeight, newVers
|
||||
return 0 // no action
|
||||
}
|
||||
|
||||
existingFields, err := decodeBlockRecordProfile([]BlockRecordRaw{*record})
|
||||
existingFields, err := DecodeBlockRecordProfile([]BlockRecordRaw{*record})
|
||||
if err != nil || len(existingFields) != 1 {
|
||||
return 3 // error blockchain corrupt
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ func printFile(file BlockRecordFile) {
|
||||
for _, tag := range file.Tags {
|
||||
switch tag.Type {
|
||||
case TagName:
|
||||
fmt.Printf(" Name %s\n", tag.Text())
|
||||
fmt.Printf(" Username %s\n", tag.Text())
|
||||
case TagFolder:
|
||||
fmt.Printf(" Folder %s\n", tag.Text())
|
||||
case TagDescription:
|
||||
|
||||
Reference in New Issue
Block a user