-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.go
62 lines (55 loc) · 988 Bytes
/
settings.go
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
package blockchain
import (
"database/sql"
mrand "math/rand"
"time"
)
func init() {
mrand.Seed(time.Now().UnixNano())
}
const (
CREATE_TABLE = `
CREATE TABLE BlockChain (
Id INTEGER PRIMARY KEY AUTOINCREMENT,
Hash VARCHAR(44) UNIQUE,
Block TEXT
);
`
)
const (
DEBUG = true
KEY_SIZE = 512
STORAGE_CHAIN = "STORAGE-CHAIN"
STORAGE_VALUE = 100
STORAGE_REWARD = 1
GENESIS_BLOCK = "GENESIS-BLOCK"
GENESIS_REWARD = 100
DIFFICULTY = 20
TXS_LIMIT = 2
START_PERCENT = 10
RAND_BYTES = 32
)
type BlockChain struct {
DB *sql.DB
}
type Block struct {
Nonce uint64
Difficulty uint8
CurrHash []byte
PrevHash []byte
Transactions []Transaction
Mapping map[string]uint64
Miner string
Signature []byte
TimeStamp string
}
type Transaction struct {
RandBytes []byte
PrevBlock []byte
Sender string
Receiver string
Value uint64
ToStorage uint64
CurrHash []byte
Signature []byte
}