Golang implemented sidechain for Bytom
Revision | 3ed12f9997d3a184ecc6521e3fc54b1250d7c2f4 (tree) |
---|---|
Time | 2019-07-15 14:55:58 |
Author | mars <mars@byto...> |
Commiter | mars |
rename dir
@@ -5,15 +5,16 @@ import ( | ||
5 | 5 | |
6 | 6 | log "github.com/sirupsen/logrus" |
7 | 7 | |
8 | - "github.com/vapor/federation/api" | |
9 | - "github.com/vapor/federation/config" | |
10 | - "github.com/vapor/federation/database" | |
11 | - "github.com/vapor/federation/synchron" | |
8 | + "github.com/vapor/toolbar/common" | |
9 | + "github.com/vapor/toolbar/federation/api" | |
10 | + "github.com/vapor/toolbar/federation/config" | |
11 | + "github.com/vapor/toolbar/federation/database" | |
12 | + "github.com/vapor/toolbar/federation/synchron" | |
12 | 13 | ) |
13 | 14 | |
14 | 15 | func main() { |
15 | 16 | cfg := config.NewConfig() |
16 | - db, err := database.NewMySQLDB(cfg.MySQLConfig) | |
17 | + db, err := common.NewMySQLDB(cfg.MySQLConfig) | |
17 | 18 | if err != nil { |
18 | 19 | log.WithField("err", err).Panic("initialize mysql db error") |
19 | 20 | } |
@@ -0,0 +1,5 @@ | ||
1 | +package main | |
2 | + | |
3 | +func main() { | |
4 | + | |
5 | +} |
@@ -0,0 +1,14 @@ | ||
1 | +package common | |
2 | + | |
3 | +type MySQLConfig struct { | |
4 | + Connection MySQLConnection `json:"connection"` | |
5 | + LogMode bool `json:"log_mode"` | |
6 | +} | |
7 | + | |
8 | +type MySQLConnection struct { | |
9 | + Host string `json:"host"` | |
10 | + Port uint `json:"port"` | |
11 | + Username string `json:"username"` | |
12 | + Password string `json:"password"` | |
13 | + DbName string `json:"database"` | |
14 | +} |
@@ -1,4 +1,4 @@ | ||
1 | -package database | |
1 | +package common | |
2 | 2 | |
3 | 3 | import ( |
4 | 4 | "fmt" |
@@ -7,10 +7,9 @@ import ( | ||
7 | 7 | "github.com/jinzhu/gorm" |
8 | 8 | |
9 | 9 | "github.com/vapor/errors" |
10 | - "github.com/vapor/federation/config" | |
11 | 10 | ) |
12 | 11 | |
13 | -func NewMySQLDB(cfg config.MySQLConfig) (*gorm.DB, error) { | |
12 | +func NewMySQLDB(cfg MySQLConfig) (*gorm.DB, error) { | |
14 | 13 | dsnTemplate := "%s:%s@tcp(%s:%d)/%s?charset=utf8&parseTime=true&loc=Local" |
15 | 14 | dsn := fmt.Sprintf(dsnTemplate, cfg.Connection.Username, cfg.Connection.Password, cfg.Connection.Host, cfg.Connection.Port, cfg.Connection.DbName) |
16 | 15 | db, err := gorm.Open("mysql", dsn) |
@@ -8,8 +8,8 @@ import ( | ||
8 | 8 | "github.com/gin-gonic/gin" |
9 | 9 | |
10 | 10 | "github.com/vapor/errors" |
11 | - "github.com/vapor/federation/common" | |
12 | - "github.com/vapor/federation/database/orm" | |
11 | + "github.com/vapor/toolbar/federation/common" | |
12 | + "github.com/vapor/toolbar/federation/database/orm" | |
13 | 13 | ) |
14 | 14 | |
15 | 15 | type listCrosschainTxsReq struct{ Display } |
@@ -10,7 +10,7 @@ import ( | ||
10 | 10 | "github.com/jinzhu/gorm" |
11 | 11 | |
12 | 12 | "github.com/vapor/errors" |
13 | - "github.com/vapor/federation/config" | |
13 | + "github.com/vapor/toolbar/federation/config" | |
14 | 14 | ) |
15 | 15 | |
16 | 16 | type Server struct { |
@@ -7,6 +7,7 @@ import ( | ||
7 | 7 | log "github.com/sirupsen/logrus" |
8 | 8 | |
9 | 9 | "github.com/vapor/crypto/ed25519/chainkd" |
10 | + "github.com/vapor/toolbar/common" | |
10 | 11 | ) |
11 | 12 | |
12 | 13 | func NewConfig() *Config { |
@@ -33,31 +34,18 @@ func NewConfigWithPath(path string) *Config { | ||
33 | 34 | } |
34 | 35 | |
35 | 36 | type Config struct { |
36 | - API API `json:"api"` | |
37 | - MySQLConfig MySQLConfig `json:"mysql"` | |
38 | - Warders []Warder `json:"warders"` | |
39 | - Quorum int `json:"quorum"` | |
40 | - Mainchain Chain `json:"mainchain"` | |
41 | - Sidechain Chain `json:"sidechain"` | |
37 | + API API `json:"api"` | |
38 | + MySQLConfig common.MySQLConfig `json:"mysql"` | |
39 | + Warders []Warder `json:"warders"` | |
40 | + Quorum int `json:"quorum"` | |
41 | + Mainchain Chain `json:"mainchain"` | |
42 | + Sidechain Chain `json:"sidechain"` | |
42 | 43 | } |
43 | 44 | |
44 | 45 | type API struct { |
45 | 46 | IsReleaseMode bool `json:"is_release_mode"` |
46 | 47 | } |
47 | 48 | |
48 | -type MySQLConfig struct { | |
49 | - Connection MySQLConnection `json:"connection"` | |
50 | - LogMode bool `json:"log_mode"` | |
51 | -} | |
52 | - | |
53 | -type MySQLConnection struct { | |
54 | - Host string `json:"host"` | |
55 | - Port uint `json:"port"` | |
56 | - Username string `json:"username"` | |
57 | - Password string `json:"password"` | |
58 | - DbName string `json:"database"` | |
59 | -} | |
60 | - | |
61 | 49 | type Warder struct { |
62 | 50 | Position uint8 `json:"position"` |
63 | 51 | XPub chainkd.XPub `json:"xpub"` |
@@ -7,7 +7,7 @@ import ( | ||
7 | 7 | "github.com/jinzhu/gorm" |
8 | 8 | |
9 | 9 | "github.com/vapor/errors" |
10 | - "github.com/vapor/federation/database/orm" | |
10 | + "github.com/vapor/toolbar/federation/database/orm" | |
11 | 11 | ) |
12 | 12 | |
13 | 13 | const ( |
@@ -1,7 +1,7 @@ | ||
1 | 1 | package orm |
2 | 2 | |
3 | 3 | import ( |
4 | - "github.com/vapor/federation/types" | |
4 | + "github.com/vapor/toolbar/federation/types" | |
5 | 5 | ) |
6 | 6 | |
7 | 7 | type Asset struct { |
@@ -1,7 +1,7 @@ | ||
1 | 1 | package orm |
2 | 2 | |
3 | 3 | import ( |
4 | - "github.com/vapor/federation/types" | |
4 | + "github.com/vapor/toolbar/federation/types" | |
5 | 5 | ) |
6 | 6 | |
7 | 7 | type Chain struct { |
@@ -5,8 +5,8 @@ import ( | ||
5 | 5 | "encoding/json" |
6 | 6 | |
7 | 7 | "github.com/vapor/errors" |
8 | - "github.com/vapor/federation/common" | |
9 | - "github.com/vapor/federation/types" | |
8 | + "github.com/vapor/toolbar/federation/common" | |
9 | + "github.com/vapor/toolbar/federation/types" | |
10 | 10 | ) |
11 | 11 | |
12 | 12 | type CrossTransaction struct { |
@@ -1,7 +1,7 @@ | ||
1 | 1 | package orm |
2 | 2 | |
3 | 3 | import ( |
4 | - "github.com/vapor/federation/types" | |
4 | + "github.com/vapor/toolbar/federation/types" | |
5 | 5 | ) |
6 | 6 | |
7 | 7 | type CrossTransactionReq struct { |
@@ -4,8 +4,8 @@ import ( | ||
4 | 4 | "encoding/json" |
5 | 5 | |
6 | 6 | "github.com/vapor/errors" |
7 | - "github.com/vapor/federation/util" | |
8 | 7 | "github.com/vapor/protocol/bc" |
8 | + "github.com/vapor/toolbar/federation/util" | |
9 | 9 | ) |
10 | 10 | |
11 | 11 | // Node can invoke the api which provide by the full node server |
@@ -16,13 +16,13 @@ import ( | ||
16 | 16 | vaporConsensus "github.com/vapor/consensus" |
17 | 17 | "github.com/vapor/consensus/segwit" |
18 | 18 | "github.com/vapor/errors" |
19 | - "github.com/vapor/federation/common" | |
20 | - "github.com/vapor/federation/config" | |
21 | - "github.com/vapor/federation/database" | |
22 | - "github.com/vapor/federation/database/orm" | |
23 | - "github.com/vapor/federation/service" | |
24 | - "github.com/vapor/federation/util" | |
25 | 19 | "github.com/vapor/protocol/bc" |
20 | + "github.com/vapor/toolbar/federation/common" | |
21 | + "github.com/vapor/toolbar/federation/config" | |
22 | + "github.com/vapor/toolbar/federation/database" | |
23 | + "github.com/vapor/toolbar/federation/database/orm" | |
24 | + "github.com/vapor/toolbar/federation/service" | |
25 | + "github.com/vapor/toolbar/federation/util" | |
26 | 26 | "github.com/vapor/wallet" |
27 | 27 | ) |
28 | 28 |
@@ -12,13 +12,13 @@ import ( | ||
12 | 12 | "github.com/vapor/consensus" |
13 | 13 | "github.com/vapor/consensus/segwit" |
14 | 14 | "github.com/vapor/errors" |
15 | - "github.com/vapor/federation/common" | |
16 | - "github.com/vapor/federation/config" | |
17 | - "github.com/vapor/federation/database" | |
18 | - "github.com/vapor/federation/database/orm" | |
19 | - "github.com/vapor/federation/service" | |
20 | 15 | "github.com/vapor/protocol/bc" |
21 | 16 | "github.com/vapor/protocol/bc/types" |
17 | + "github.com/vapor/toolbar/federation/common" | |
18 | + "github.com/vapor/toolbar/federation/config" | |
19 | + "github.com/vapor/toolbar/federation/database" | |
20 | + "github.com/vapor/toolbar/federation/database/orm" | |
21 | + "github.com/vapor/toolbar/federation/service" | |
22 | 22 | "github.com/vapor/wallet" |
23 | 23 | ) |
24 | 24 |
@@ -7,8 +7,8 @@ import ( | ||
7 | 7 | |
8 | 8 | "github.com/vapor/crypto" |
9 | 9 | "github.com/vapor/crypto/ed25519/chainkd" |
10 | - "github.com/vapor/federation/config" | |
11 | 10 | "github.com/vapor/protocol/vm/vmutil" |
11 | + "github.com/vapor/toolbar/federation/config" | |
12 | 12 | ) |
13 | 13 | |
14 | 14 | func ParseFedProg(warders []config.Warder, quorum int) []byte { |
@@ -0,0 +1 @@ | ||
1 | +package orm |
@@ -0,0 +1 @@ | ||
1 | +package orm |