-package types
+package common
import (
"fmt"
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:"-"`
}
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:"-"`
}
"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 {
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
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")
}
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"`
)
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")