OSDN Git Service

Voter reward (#286)
authorwz <mars@bytom.io>
Mon, 15 Jul 2019 08:08:57 +0000 (16:08 +0800)
committerPaladz <yzhu101@uottawa.ca>
Mon, 15 Jul 2019 08:08:57 +0000 (16:08 +0800)
* rename dir

* add database

* fix

* fix

cmd/reward/main.go [new file with mode: 0644]
toolbar/reward/config/config.go [new file with mode: 0644]
toolbar/reward/database/dump_reward.sql [new file with mode: 0644]
toolbar/reward/database/orm/block_state.go [new file with mode: 0644]
toolbar/reward/database/orm/vote_utxo.go [new file with mode: 0644]

diff --git a/cmd/reward/main.go b/cmd/reward/main.go
new file mode 100644 (file)
index 0000000..7905807
--- /dev/null
@@ -0,0 +1,5 @@
+package main
+
+func main() {
+
+}
diff --git a/toolbar/reward/config/config.go b/toolbar/reward/config/config.go
new file mode 100644 (file)
index 0000000..d912156
--- /dev/null
@@ -0,0 +1 @@
+package config
diff --git a/toolbar/reward/database/dump_reward.sql b/toolbar/reward/database/dump_reward.sql
new file mode 100644 (file)
index 0000000..807c67d
--- /dev/null
@@ -0,0 +1,29 @@
+SET NAMES utf8mb4;
+SET FOREIGN_KEY_CHECKS = 0;
+
+-- ----------------------------
+-- Table structure for block_state
+-- ----------------------------
+DROP TABLE IF EXISTS `block_state`;
+CREATE TABLE `block_state`  (
+  `height` int(11) NOT NULL,
+  `block_hash` varchar(64) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL
+) ENGINE = InnoDB DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Table structure for vote
+-- ----------------------------
+DROP TABLE IF EXISTS `vote`;
+CREATE TABLE `vote`  (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `xpub` varchar(128) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
+  `voter_address` varchar(62) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
+  `vote_height` int(11) NOT NULL,
+  `vote_num` int(11) NOT NULL,
+  `veto_height` int(11) NOT NULL,
+  `output_id` varchar(64) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
+  PRIMARY KEY (`id`) USING BTREE,
+  UNIQUE INDEX `xpub`(`xpub`, `vote_height`, `output_id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 6 DEFAULT CHARSET=utf8;
+
+SET FOREIGN_KEY_CHECKS = 1;
diff --git a/toolbar/reward/database/orm/block_state.go b/toolbar/reward/database/orm/block_state.go
new file mode 100644 (file)
index 0000000..6fdd155
--- /dev/null
@@ -0,0 +1,6 @@
+package orm
+
+type BlockState struct {
+       Height    uint64
+       BlockHash string
+}
diff --git a/toolbar/reward/database/orm/vote_utxo.go b/toolbar/reward/database/orm/vote_utxo.go
new file mode 100644 (file)
index 0000000..4395181
--- /dev/null
@@ -0,0 +1,11 @@
+package orm
+
+type Utxo struct {
+       ID           uint64 `gorm:"primary_key"`
+       Xpub         string
+       VoterAddress string
+       VoteHeight   uint64
+       VoteNum      uint64
+       VetoHeight   uint64
+       OutputID     string
+}