log "github.com/sirupsen/logrus"
- "github.com/vapor/federation/api"
- "github.com/vapor/federation/config"
- "github.com/vapor/federation/database"
- "github.com/vapor/federation/synchron"
+ "github.com/vapor/toolbar/federation/api"
+ "github.com/vapor/toolbar/federation/config"
+ "github.com/vapor/toolbar/federation/database"
+ "github.com/vapor/toolbar/common"
+ "github.com/vapor/toolbar/federation/synchron"
)
func main() {
cfg := config.NewConfig()
- db, err := database.NewMySQLDB(cfg.MySQLConfig)
+ db, err := common.NewMySQLDB(cfg.MySQLConfig)
if err != nil {
log.WithField("err", err).Panic("initialize mysql db error")
}
--- /dev/null
+package common
+
+type MySQLConfig struct {
+ Connection MySQLConnection `json:"connection"`
+ LogMode bool `json:"log_mode"`
+}
+
+type MySQLConnection struct {
+ Host string `json:"host"`
+ Port uint `json:"port"`
+ Username string `json:"username"`
+ Password string `json:"password"`
+ DbName string `json:"database"`
+}
-package database
+package common
import (
"fmt"
"github.com/jinzhu/gorm"
"github.com/vapor/errors"
- "github.com/vapor/federation/config"
)
-func NewMySQLDB(cfg config.MySQLConfig) (*gorm.DB, error) {
+func NewMySQLDB(cfg MySQLConfig) (*gorm.DB, error) {
dsnTemplate := "%s:%s@tcp(%s:%d)/%s?charset=utf8&parseTime=true&loc=Local"
dsn := fmt.Sprintf(dsnTemplate, cfg.Connection.Username, cfg.Connection.Password, cfg.Connection.Host, cfg.Connection.Port, cfg.Connection.DbName)
db, err := gorm.Open("mysql", dsn)
"github.com/gin-gonic/gin"
"github.com/vapor/errors"
- "github.com/vapor/federation/common"
- "github.com/vapor/federation/database/orm"
+ "github.com/vapor/toolbar/federation/common"
+ "github.com/vapor/toolbar/federation/database/orm"
)
type listCrosschainTxsReq struct{ Display }
"github.com/jinzhu/gorm"
"github.com/vapor/errors"
- "github.com/vapor/federation/config"
+ "github.com/vapor/toolbar/federation/config"
)
type Server struct {
log "github.com/sirupsen/logrus"
vaporJson "github.com/vapor/encoding/json"
+ "github.com/vapor/toolbar/common"
)
func NewConfig() *Config {
type Config struct {
API API `json:"api"`
- MySQLConfig MySQLConfig `json:"mysql"`
+ MySQLConfig common.MySQLConfig `json:"mysql"`
FederationProg vaporJson.HexBytes `json:"federation_prog"`
Mainchain Chain `json:"mainchain"`
Sidechain Chain `json:"sidechain"`
IsReleaseMode bool `json:"is_release_mode"`
}
-type MySQLConfig struct {
- Connection MySQLConnection `json:"connection"`
- LogMode bool `json:"log_mode"`
-}
-
-type MySQLConnection struct {
- Host string `json:"host"`
- Port uint `json:"port"`
- Username string `json:"username"`
- Password string `json:"password"`
- DbName string `json:"database"`
-}
-
type Chain struct {
Name string `json:"name"`
Upstream string `json:"upstream"`
"github.com/jinzhu/gorm"
"github.com/vapor/errors"
- "github.com/vapor/federation/database/orm"
+ "github.com/vapor/toolbar/federation/database/orm"
)
const (
package orm
import (
- "github.com/vapor/federation/types"
+ "github.com/vapor/toolbar/federation/types"
)
type Asset struct {
package orm
import (
- "github.com/vapor/federation/types"
+ "github.com/vapor/toolbar/federation/types"
)
type Chain struct {
"encoding/json"
"github.com/vapor/errors"
- "github.com/vapor/federation/common"
- "github.com/vapor/federation/types"
+ "github.com/vapor/toolbar/federation/common"
+ "github.com/vapor/toolbar/federation/types"
)
type CrossTransaction struct {
package orm
import (
- "github.com/vapor/federation/types"
+ "github.com/vapor/toolbar/federation/types"
)
type CrossTransactionReq struct {
"encoding/json"
"github.com/vapor/errors"
- "github.com/vapor/federation/util"
+ "github.com/vapor/toolbar/federation/util"
"github.com/vapor/protocol/bc"
)
"github.com/vapor/consensus"
"github.com/vapor/errors"
- "github.com/vapor/federation/common"
- "github.com/vapor/federation/config"
- "github.com/vapor/federation/database"
- "github.com/vapor/federation/database/orm"
- "github.com/vapor/federation/service"
+ "github.com/vapor/toolbar/federation/common"
+ "github.com/vapor/toolbar/federation/config"
+ "github.com/vapor/toolbar/federation/database"
+ "github.com/vapor/toolbar/federation/database/orm"
+ "github.com/vapor/toolbar/federation/service"
"github.com/vapor/protocol/bc"
)
"github.com/vapor/consensus"
"github.com/vapor/errors"
- "github.com/vapor/federation/common"
- "github.com/vapor/federation/config"
- "github.com/vapor/federation/database"
- "github.com/vapor/federation/database/orm"
- "github.com/vapor/federation/service"
+ "github.com/vapor/toolbar/federation/common"
+ "github.com/vapor/toolbar/federation/config"
+ "github.com/vapor/toolbar/federation/database"
+ "github.com/vapor/toolbar/federation/database/orm"
+ "github.com/vapor/toolbar/federation/service"
"github.com/vapor/protocol/bc"
"github.com/vapor/protocol/bc/types"
)