OSDN Git Service

mv timestamp type def
authorHAOYUatHZ <haoyu@protonmail.com>
Tue, 3 Sep 2019 07:11:32 +0000 (15:11 +0800)
committerHAOYUatHZ <haoyu@protonmail.com>
Tue, 3 Sep 2019 07:11:32 +0000 (15:11 +0800)
toolbar/common/types.go [moved from toolbar/federation/types/types.go with 96% similarity]
toolbar/federation/database/orm/asset.go
toolbar/federation/database/orm/chain.go
toolbar/federation/database/orm/cross_transaction.go
toolbar/federation/database/orm/cross_transaction_req.go
toolbar/precognitive/monitor/connection.go

similarity index 96%
rename from toolbar/federation/types/types.go
rename to toolbar/common/types.go
index e3f8f48..18e3b0e 100644 (file)
@@ -1,4 +1,4 @@
-package types
+package common
 
 import (
        "fmt"
index 61c0287..1d39d49 100644 (file)
@@ -1,15 +1,15 @@
 package orm
 
 import (
-       "github.com/vapor/toolbar/federation/types"
+       "github.com/vapor/toolbar/common"
 )
 
 type Asset struct {
-       ID              uint64          `gorm:"primary_key;foreignkey:ID" json:"-"`
-       AssetID         string          `json:"asset_id"`
-       IssuanceProgram string          `json:"-"`
-       VMVersion       uint64          `json:"-"`
-       Definition      string          `json:"-"`
-       CreatedAt       types.Timestamp `json:"-"`
-       UpdatedAt       types.Timestamp `json:"-"`
+       ID              uint64           `gorm:"primary_key;foreignkey:ID" json:"-"`
+       AssetID         string           `json:"asset_id"`
+       IssuanceProgram string           `json:"-"`
+       VMVersion       uint64           `json:"-"`
+       Definition      string           `json:"-"`
+       CreatedAt       common.Timestamp `json:"-"`
+       UpdatedAt       common.Timestamp `json:"-"`
 }
index afbdbe8..92656eb 100644 (file)
@@ -1,14 +1,14 @@
 package orm
 
 import (
-       "github.com/vapor/toolbar/federation/types"
+       "github.com/vapor/toolbar/common"
 )
 
 type Chain struct {
-       ID          uint64          `gorm:"primary_key" json:"-"`
-       Name        string          `json:"name"`
-       BlockHeight uint64          `json:"block_height"`
-       BlockHash   string          `json:"block_hash"`
-       CreatedAt   types.Timestamp `json:"-"`
-       UpdatedAt   types.Timestamp `json:"-"`
+       ID          uint64           `gorm:"primary_key" json:"-"`
+       Name        string           `json:"name"`
+       BlockHeight uint64           `json:"block_height"`
+       BlockHash   string           `json:"block_hash"`
+       CreatedAt   common.Timestamp `json:"-"`
+       UpdatedAt   common.Timestamp `json:"-"`
 }
index 9d2eb29..6c424db 100644 (file)
@@ -5,8 +5,8 @@ import (
        "encoding/json"
 
        "github.com/vapor/errors"
-       "github.com/vapor/toolbar/federation/common"
-       "github.com/vapor/toolbar/federation/types"
+       "github.com/vapor/toolbar/common"
+       fedCommon "github.com/vapor/toolbar/federation/common"
 )
 
 type CrossTransaction struct {
@@ -25,8 +25,8 @@ type CrossTransaction struct {
        DestTxIndex          sql.NullInt64  `sql:"default:null"`
        DestTxHash           sql.NullString `sql:"default:null"`
        Status               uint8
-       CreatedAt            types.Timestamp
-       UpdatedAt            types.Timestamp
+       CreatedAt            common.Timestamp
+       UpdatedAt            common.Timestamp
 
        Chain *Chain `gorm:"foreignkey:ChainID"`
        Reqs  []*CrossTransactionReq
@@ -35,10 +35,10 @@ type CrossTransaction struct {
 func (c *CrossTransaction) MarshalJSON() ([]byte, error) {
        var status string
        switch c.Status {
-       case common.CrossTxPendingStatus:
-               status = common.CrossTxPendingStatusLabel
-       case common.CrossTxCompletedStatus:
-               status = common.CrossTxCompletedStatusLabel
+       case fedCommon.CrossTxPendingStatus:
+               status = fedCommon.CrossTxPendingStatusLabel
+       case fedCommon.CrossTxCompletedStatus:
+               status = fedCommon.CrossTxCompletedStatusLabel
        default:
                return nil, errors.New("unknown cross-chain tx status")
        }
index 907cd3f..2719561 100644 (file)
@@ -1,20 +1,20 @@
 package orm
 
 import (
-       "github.com/vapor/toolbar/federation/types"
+       "github.com/vapor/toolbar/common"
 )
 
 type CrossTransactionReq struct {
-       ID                 uint64          `gorm:"primary_key" json:"-"`
-       CrossTransactionID uint64          `json:"-"`
-       SourcePos          uint64          `json:"-"`
-       AssetID            uint64          `json:"-"`
-       AssetAmount        uint64          `json:"amount"`
-       Script             string          `json:"-"`
-       FromAddress        string          `json:"from_address"`
-       ToAddress          string          `json:"to_address"`
-       CreatedAt          types.Timestamp `json:"-"`
-       UpdatedAt          types.Timestamp `json:"-"`
+       ID                 uint64           `gorm:"primary_key" json:"-"`
+       CrossTransactionID uint64           `json:"-"`
+       SourcePos          uint64           `json:"-"`
+       AssetID            uint64           `json:"-"`
+       AssetAmount        uint64           `json:"amount"`
+       Script             string           `json:"-"`
+       FromAddress        string           `json:"from_address"`
+       ToAddress          string           `json:"to_address"`
+       CreatedAt          common.Timestamp `json:"-"`
+       UpdatedAt          common.Timestamp `json:"-"`
 
        CrossTransaction *CrossTransaction `gorm:"foreignkey:CrossTransactionID" json:"-"`
        Asset            *Asset            `json:"asset"`
index 6072377..c28d855 100644 (file)
@@ -11,7 +11,7 @@ import (
 )
 
 func (m *monitor) connectionRoutine() {
-       ticker := time.NewTicker(time.Duration(m.cfg.CheckFreqMinutes) * time.Minute)
+       ticker := time.NewTicker(time.Duration(m.cfg.CheckFreqMinutes/3) * time.Second)
        for ; true; <-ticker.C {
                if err := m.dialNodes(); err != nil {
                        log.WithFields(log.Fields{"err": err}).Error("dialNodes")