diff --git a/.travis.yml b/.travis.yml index 7af413e2..e2ff075a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ +language: go -go_import_path: github.com/IBAX/go-ibax +env: GO111MODULE=on -install: true - -script: go build github.com/IBAX/go-ibax +go: + - 1.12.x + - master diff --git a/packages/crypto/hasher_test.go b/packages/crypto/hasher_test.go index 25d73df6..fa884e92 100644 --- a/packages/crypto/hasher_test.go +++ b/packages/crypto/hasher_test.go @@ -3,11 +3,7 @@ package crypto import ( "fmt" "testing" -) -func TestGetHasher(t *testing.T) { - h := getHasher() - msg := []byte("Hello") hmacMsg, err := h.getHMAC(secret, message) if err != nil { diff --git a/packages/daemons/block_generator.go b/packages/daemons/block_generator.go index dd02df05..49fc8fb3 100644 --- a/packages/daemons/block_generator.go +++ b/packages/daemons/block_generator.go @@ -119,16 +119,6 @@ func BlockGenerator(ctx context.Context, d *daemon) error { txs, err := dtx.RunForDelayBlockID(prevBlock.BlockID + 1) if err != nil { - return err - } - - trs, err := processTransactions(d.logger, txs, done, st.Unix()) - if err != nil { - return err - } - - // Block generation will be started only if we have transactions - if len(trs) == 0 { return nil } @@ -176,6 +166,9 @@ func processTransactions(logger *log.Entry, txs []*model.Transaction, done <-cha p := new(transaction.Transaction) //verify transactions + //err := transaction.ProcessTransactionsQueue(p.DbTransaction) + //if err != nil { + // return nil, err //} trs, err := model.GetAllUnusedTransactions(p.DbTransaction, syspar.GetMaxTxCount()) diff --git a/packages/migration/obs/obs_data_contracts.go b/packages/migration/obs/obs_data_contracts.go index f1020c16..813bbf8c 100644 --- a/packages/migration/obs/obs_data_contracts.go +++ b/packages/migration/obs/obs_data_contracts.go @@ -953,20 +953,6 @@ VALUES "account": $account, "pub": $pub, "amount": $amount, - "ecosystem": 1 - }) - } -} -', '%[1]d', 'ContractConditions("NodeOwnerCondition")', '1', '%[1]d'), - (next_id('1_contracts'), 'NodeOwnerCondition', 'contract NodeOwnerCondition { - conditions { - $raw_honor_nodes = SysParamString("honor_nodes") - if Size($raw_honor_nodes) == 0 { - ContractConditions("MainCondition") - } else { - $honor_nodes = JSONDecode($raw_honor_nodes) - var i int - while i < Len($honor_nodes) { $fn = $honor_nodes[i] if $fn["key_id"] == $key_id { return true @@ -1087,6 +1073,15 @@ VALUES $DataMimeType = "application/octet-stream" } if $Id != 0 { + DBUpdate("@1binaries", $Id, {"data": $Data, "hash": hash, "mime_type": $DataMimeType}) + } else { + $Id = DBInsert("@1binaries", {"app_id": $ApplicationId, "account": $UserID, + "name": $Name, "data": $Data, "hash": hash, "mime_type": $DataMimeType, "ecosystem": $ecosystem_id}) + } + $result = $Id + } +} +', '%[1]d', 'ContractConditions("MainCondition")', '1', '%[1]d'), (next_id('1_contracts'), 'UploadFile', 'contract UploadFile { data { ApplicationId int diff --git a/packages/model/blockinterface.go b/packages/model/blockinterface.go index c96a24f4..57e98b54 100644 --- a/packages/model/blockinterface.go +++ b/packages/model/blockinterface.go @@ -7,6 +7,15 @@ package model import "github.com/IBAX-io/go-ibax/packages/converter" +// BlockInterface is model +type BlockInterface struct { + ecosystem int64 + ID int64 `gorm:"primary_key;not null" json:"id,omitempty"` + Name string `gorm:"not null" json:"name,omitempty"` + Value string `gorm:"not null" json:"value,omitempty"` + Conditions string `gorm:"not null" json:"conditions,omitempty"` +} + // SetTablePrefix is setting table prefix func (bi *BlockInterface) SetTablePrefix(prefix string) { bi.ecosystem = converter.StrToInt64(prefix) @@ -22,12 +31,3 @@ func (bi BlockInterface) TableName() string { // Get is retrieving model from database func (bi *BlockInterface) Get(name string) (bool, error) { - return isFound(DBConn.Where("ecosystem=? and name = ?", bi.ecosystem, name).First(bi)) -} - -// GetByApp returns all interface blocks belonging to selected app -func (bi *BlockInterface) GetByApp(appID int64, ecosystemID int64) ([]BlockInterface, error) { - var result []BlockInterface - err := DBConn.Select("id, name").Where("app_id = ? and ecosystem = ?", appID, ecosystemID).Find(&result).Error - return result, err -} diff --git a/packages/model/database.go b/packages/model/database.go index 7272289c..cb77eaf8 100644 --- a/packages/model/database.go +++ b/packages/model/database.go @@ -39,9 +39,9 @@ func GetRowsInfo(rows *sql.Rows,sqlQuest string) ([]map[string]string, error) { err = rows.Scan(scanArgs...) if err != nil { return result, fmt.Errorf("getRows scan err:%s in query %s", err, sqlQuest) - } - var value string - rez := make(map[string]string) + value = string(col) + } + } rez[columns[i]] = value } result = append(result, rez) diff --git a/packages/model/signatures.go b/packages/model/signatures.go index a41c1b64..6ca74e18 100644 --- a/packages/model/signatures.go +++ b/packages/model/signatures.go @@ -1,6 +1,3 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) IBAX. All rights reserved. -package model // Signature is model type Signature struct { diff --git a/packages/model/subnode_src_data_status.go b/packages/model/subnode_src_data_status.go index b66897ab..26581ba4 100644 --- a/packages/model/subnode_src_data_status.go +++ b/packages/model/subnode_src_data_status.go @@ -13,14 +13,6 @@ type SubNodeSrcDataStatus struct { Data []byte `gorm:"column:data;not null" json:"data"` DataInfo string `gorm:"type:jsonb" json:"data_info"` TranMode int64 `gorm:"not null" json:"tran_mode"` - //SubNodeSrcPubkey string `gorm:"not null" json:"subnode_src_pubkey"` - SubNodeSrcPubkey string `gorm:"column:subnode_src_pubkey;not null" json:"subnode_src_pubkey"` - //SubNodeDestPubkey string `gorm:"not null" json:"subnode_dest_pubkey"` - SubNodeDestPubkey string `gorm:"column:subnode_dest_pubkey;not null" json:"subnode_dest_pubkey"` - //SubNodeDestIP string `gorm:"not null" json:"subnode_dest_ip"` - SubNodeDestIP string `gorm:"column:subnode_dest_ip;not null" json:"subnode_dest_ip"` - //SubNodeAgentPubkey string `gorm:"not null" json:"subnode_agent_pubkey"` - SubNodeAgentPubkey string `gorm:"column:subnode_agent_pubkey;not null" json:"subnode_agent_pubkey"` //SubNodeAgentIP string `gorm:"not null" json:"subnode_agent_ip"` SubNodeAgentIP string `gorm:"column:subnode_agent_ip;not null" json:"subnode_agent_ip"` AgentMode int64 `gorm:"not null" json:"agent_mode"` @@ -50,6 +42,9 @@ func (m *SubNodeSrcDataStatus) GetAll() ([]SubNodeSrcDataStatus, error) { var result []SubNodeSrcDataStatus err := DBConn.Find(&result).Error return result, err +} +func (m *SubNodeSrcDataStatus) GetOneByID() (*SubNodeSrcDataStatus, error) { + err := DBConn.Where("id=?", m.ID).First(&m).Error return m, err } diff --git a/packages/model/vde_src_task_status.go b/packages/model/vde_src_task_status.go index 52370ca3..d2f912b2 100644 --- a/packages/model/vde_src_task_status.go +++ b/packages/model/vde_src_task_status.go @@ -105,16 +105,23 @@ func (m *VDESrcTaskFromScheStatus) GetAll() ([]VDESrcTaskFromScheStatus, error) var result []VDESrcTaskFromScheStatus err := DBConn.Find(&result).Error return result, err - err := DBConn.Where("task_uuid=?", TaskUUID).First(&m).Error +} +func (m *VDESrcTaskFromScheStatus) GetOneByID() (*VDESrcTaskFromScheStatus, error) { + err := DBConn.Where("id=?", m.ID).First(&m).Error return m, err } -func (m *VDESrcTaskFromScheStatus) GetOneByChainState(ChainState int64) (bool, error) { - return isFound(DBConn.Where("chain_state = ?", ChainState).First(m)) +func (m *VDESrcTaskFromScheStatus) GetAllByTaskUUID(TaskUUID string) ([]VDESrcTaskFromScheStatus, error) { + result := make([]VDESrcTaskFromScheStatus, 0) + err := DBConn.Table("vde_src_task_from_sche_status").Where("task_uuid = ?", TaskUUID).Find(&result).Error + return result, err +} + +func (m *VDESrcTaskFromScheStatus) GetOneByTaskUUID(TaskUUID string) (*VDESrcTaskFromScheStatus, error) { + err := DBConn.Where("task_uuid=?", TaskUUID).First(&m).Error + return m, err } -func (m *VDESrcTaskFromScheStatus) GetAllByChainState(ChainState int64) ([]VDESrcTaskFromScheStatus, error) { - result := make([]VDESrcTaskFromScheStatus, 0) err := DBConn.Table("vde_src_task_from_sche_status").Where("chain_state = ?", ChainState).Find(&result).Error return result, err } diff --git a/packages/obsmanager/config.go b/packages/obsmanager/config.go index e53607e2..12cb7004 100644 --- a/packages/obsmanager/config.go +++ b/packages/obsmanager/config.go @@ -26,6 +26,15 @@ type ChildOBSConfig struct { ConfigFileName string LogTo string LogLevel string + HTTPPort int +} + +func (c ChildOBSConfig) configCommand() *exec.Cmd { + + args := []string{ + fmt.Sprintf("--path=%s", c.configPath()), + fmt.Sprintf("--dbUser=%s", c.DBUser), + fmt.Sprintf("--dbPassword=%s", c.DBPassword), fmt.Sprintf("--dbName=%s", c.Name), fmt.Sprintf("--httpPort=%d", c.HTTPPort), fmt.Sprintf("--dataDir=%s", c.Directory), diff --git a/packages/utils/rand_test.go b/packages/utils/rand_test.go index 28df9ea5..e9674224 100644 --- a/packages/utils/rand_test.go +++ b/packages/utils/rand_test.go @@ -5,6 +5,15 @@ package utils import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestRand(t *testing.T) { + cases := [][]int64{ + {3434102771992637744, 1523931518789473682}, + {3434102771992637744, 1523931518789473682}, } rand := NewRand(0) @@ -12,6 +21,3 @@ import ( r := rand.BytesSeed([]byte("reset")) for _, v := range values { assert.Equal(t, v, r.Int63()) - } - } -}