Skip to content

202 node reciepts collection #265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
Sep 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
52ebe24
this commit to prettify with fmt
astaphobia Sep 9, 2019
d713796
Merge branch 'develop' of github.com:zoobc/zoobc-core into 202-node-r…
astaphobia Sep 9, 2019
17b5cad
this commit to fixed merged conflicts
astaphobia Sep 10, 2019
1ba9af8
this commit to fixed conflict files
astaphobia Sep 11, 2019
5980251
this commit to fixed imports
astaphobia Sep 11, 2019
0f0d3f3
Merge branch 'develop' of github.com:zoobc/zoobc-core into 202-node-r…
astaphobia Sep 13, 2019
dbb5faa
Merge branch 'develop' of github.com:zoobc/zoobc-core into 202-node-r…
astaphobia Sep 16, 2019
f3f4746
this commit to add batchReceiptQuert
astaphobia Sep 16, 2019
cd21841
this commit to add batch_receipt and merke_tree migration
astaphobia Sep 16, 2019
4f50c32
this commit to fixed migration bug
astaphobia Sep 17, 2019
ed6bb7e
this commit to fixed test cases migration
astaphobia Sep 17, 2019
cf3d61b
this commit to add merkle_tree and batch_receipt query
astaphobia Sep 17, 2019
7fe58ba
this commit to add receipt_batch_max const
astaphobia Sep 17, 2019
2afdb0c
this commit to add GetSignedReceiptBytes
astaphobia Sep 17, 2019
9e76a75
this commit to ensure params of updated function
astaphobia Sep 17, 2019
a13443f
this commit to ensure params of updated function
astaphobia Sep 17, 2019
5ce97f3
this commit to fmt
astaphobia Sep 17, 2019
ce83e2a
this commit to fixed conflicts
astaphobia Sep 17, 2019
4c2b3b8
this commit to modify golangci config
astaphobia Sep 23, 2019
c9a2105
this commit to fixed migration fail
astaphobia Sep 23, 2019
f8304c4
this commit to add interface func batchReceipt Query
astaphobia Sep 23, 2019
b35bf4e
this commit to prettify codes
astaphobia Sep 23, 2019
bd9617a
this commit to add ReceiptBatchMaximum const
astaphobia Sep 23, 2019
ac82d7e
this commit to add merkletree query interface and another func into r…
astaphobia Sep 23, 2019
da2229f
this commit to intialize whole new fields PeerServiceClient
astaphobia Sep 23, 2019
bfe01e8
this commit to fixed merge conflicts
astaphobia Sep 23, 2019
05aa509
this commit to catch error
astaphobia Sep 23, 2019
734a476
this commit rename column receipt_merkle_root to rmr_linked
astaphobia Sep 24, 2019
e354a2e
this commit to add p2p service build
astaphobia Sep 24, 2019
1470c2b
this commit to add model proto
astaphobia Sep 24, 2019
07298cd
this commit to update query receipt affected
astaphobia Sep 24, 2019
0abb1ca
this commit to update that after update proto
astaphobia Sep 24, 2019
0db1653
this comit to fixed merge conflict
astaphobia Sep 24, 2019
68b8b84
this commit to fixed merge conflicts
astaphobia Sep 24, 2019
37bb9fd
this commit to fixed merge conflict
astaphobia Sep 24, 2019
e8c2e31
this commit to fix golangci-lint
astaphobia Sep 24, 2019
b649bda
this commit to fix schema
astaphobia Sep 24, 2019
81bd977
this commit to fixed merge
astaphobia Sep 24, 2019
bb269a3
this commit to fix db statement and default batchReceiptQuery limit
astaphobia Sep 24, 2019
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
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ linters-settings:
goimports:
local-prefixes: github.com/zoobc/zoobc-core
gocritic:
settings:
hugeParam:
sizeThreshold: 512
enabled-tags:
- performance
- style
Expand Down
176 changes: 88 additions & 88 deletions ZooBC.postman_collection.json
Original file line number Diff line number Diff line change
@@ -1,90 +1,90 @@
{
"info": {
"_postman_id": "e8cb55b1-5c13-4894-8106-52f4bf019eee",
"name": "ZooBC",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "blocks",
"item": [
{
"name": "GetBlocks",
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "{{host}}/v1/block/GetBlocks?Limit=10&Height=0&Chaintype=0",
"host": [
"{{host}}"
],
"path": [
"v1",
"block",
"GetBlocks"
],
"query": [
{
"key": "Limit",
"value": "10"
},
{
"key": "Height",
"value": "0"
},
{
"key": "Chaintype",
"value": "0"
}
]
}
},
"response": []
},
{
"name": "GetBlock",
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "{{host}}/v1/block/GetBlock?ID=-8826204794314169398",
"host": [
"{{host}}"
],
"path": [
"v1",
"block",
"GetBlock"
],
"query": [
{
"key": "ID",
"value": "-8826204794314169398"
},
{
"key": "Height",
"value": "20",
"disabled": true
},
{
"key": "Chaintype",
"value": "0",
"disabled": true
}
]
}
},
"response": []
}
]
}
]
"info": {
"_postman_id": "e8cb55b1-5c13-4894-8106-52f4bf019eee",
"name": "ZooBC",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "blocks",
"item": [
{
"name": "GetBlocks",
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "{{host}}/v1/block/GetBlocks?Limit=10&Height=0&Chaintype=0",
"host": [
"{{host}}"
],
"path": [
"v1",
"block",
"GetBlocks"
],
"query": [
{
"key": "Limit",
"value": "10"
},
{
"key": "Height",
"value": "0"
},
{
"key": "Chaintype",
"value": "0"
}
]
}
},
"response": []
},
{
"name": "GetBlock",
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "{{host}}/v1/block/GetBlock?ID=-8826204794314169398",
"host": [
"{{host}}"
],
"path": [
"v1",
"block",
"GetBlock"
],
"query": [
{
"key": "ID",
"value": "-8826204794314169398"
},
{
"key": "Height",
"value": "20",
"disabled": true
},
{
"key": "Chaintype",
"value": "0",
"disabled": true
}
]
}
},
"response": []
}
]
}
]
}
1 change: 0 additions & 1 deletion api/handler/nodeHardwareHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package handler

import (
"io"

"time"

"github.com/zoobc/zoobc-core/api/service"
Expand Down
4 changes: 2 additions & 2 deletions common/constant/participationScore.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package constant
const (
// ScalarReceiptScore the converter score to avoid calculation in float number
ScalarReceiptScore float32 = 1000000
// LinkedReceiptScore the score for each receipt that proved have relation with prevoius published receipt via merkle root
// LinkedReceiptScore the score for each receipt that proved have relation with previous published receipt via merkle root
LinkedReceiptScore float32 = 2
// LinkedReceiptScore the score for each receipt that can't proved have relation with prevoius published receipt via merkle root
// LinkedReceiptScore the score for each receipt that can't proved have relation with previous published receipt via merkle root
UnlinkedReceiptScore float32 = 0.5
// MaxScoreChange the maximum score that node wll get
MaxScoreChange int64 = 10 * int64(ScalarReceiptScore)
Expand Down
1 change: 1 addition & 0 deletions common/constant/receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ package constant
const (
ReceiptDatumTypeBlock = uint32(1)
ReceiptDatumTypeTransaction = uint32(2)
ReceiptBatchMaximum = uint32(8) // 256 in production
)
60 changes: 37 additions & 23 deletions common/database/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package database
import (
"fmt"

log "github.com/sirupsen/logrus"
"github.com/zoobc/zoobc-core/common/query"
)

Expand All @@ -27,11 +26,9 @@ and initialize versions
func (m *Migration) Init() error {

if m.Query != nil {
rows, _ := m.Query.ExecuteSelect("SELECT version FROM migration;", false)
if rows != nil {
defer rows.Close()
var version int
_ = rows.Scan(&version)
var version int
err := m.Query.ExecuteSelectRow("SELECT version FROM migration;").Scan(&version)
if err == nil {
m.CurrentVersion = &version
}

Expand Down Expand Up @@ -135,16 +132,36 @@ func (m *Migration) Init() error {
);`,
`
CREATE TABLE IF NOT EXISTS "node_receipt" (
"sender_public_key" BLOB,
"sender_public_key" BLOB,
"recipient_public_key" BLOB,
"datum_type" INTEGER,
"datum_hash" BLOB,
"reference_block_height" INTEGER,
"reference_block_hash" BLOB,
"receipt_merkle_root" BLOB,
"rmr_linked" BLOB,
"recipient_signature" BLOB,
"rmr" BLOB,
"rmr_index" INTEGER
)
`,
`
CREATE TABLE IF NOT EXISTS "batch_receipt" (
"sender_public_key" BLOB,
"recipient_public_key" BLOB,
"datum_type" INTEGER,
"datum_hash" BLOB,
"reference_block_height" INTEGER,
"reference_block_hash" BLOB,
"rmr_linked" BLOB,
"recipient_signature" BLOB
)
`,
`
CREATE TABLE IF NOT EXISTS "merkle_tree" (
"id" BLOB,
"tree" BLOB
)
`,
}
return nil
}
Expand All @@ -160,29 +177,25 @@ func (m *Migration) Apply() error {

var (
migrations = m.Versions
err error
)

if m.CurrentVersion != nil {
migrations = m.Versions[*m.CurrentVersion:]
migrations = m.Versions[*m.CurrentVersion+1:]
}

for version, query := range migrations {
var err error
version := version
err = m.Query.BeginTx()
if err != nil {
log.Warn(err)
}
for v, query := range migrations {
version := v
_ = m.Query.BeginTx()
err = m.Query.ExecuteTransaction(query)
if err != nil {
log.Warn(err)
return err
}

if m.CurrentVersion != nil {
err = m.Query.ExecuteTransaction(`UPDATE "migration"
SET "version" = ?, "created_date" = datetime('now');`, *m.CurrentVersion)
SET "version" = ?, "created_date" = datetime('now');`, *m.CurrentVersion+1)
if err != nil {
log.Warn(err)
return err
}
} else {
err = m.Query.ExecuteTransaction(`
Expand All @@ -194,13 +207,14 @@ func (m *Migration) Apply() error {
0,
datetime('now')
);
`)
`)
if err != nil {
log.Warn(err)
return err
}
}
err = m.Query.CommitTx()

m.CurrentVersion = &version
err := m.Query.CommitTx()
if err != nil {
return err
}
Expand Down
Loading