Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
powerpook committed Aug 28, 2020
1 parent 6f071b1 commit a430e4a
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 63 deletions.
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 0 additions & 4 deletions packages/crypto/hasher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 3 additions & 10 deletions packages/daemons/block_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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())
Expand Down
23 changes: 9 additions & 14 deletions packages/migration/obs/obs_data_contracts.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions packages/model/blockinterface.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
6 changes: 3 additions & 3 deletions packages/model/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions packages/model/signatures.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) IBAX. All rights reserved.
package model

// Signature is model
type Signature struct {
Expand Down
11 changes: 3 additions & 8 deletions packages/model/subnode_src_data_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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
}

Expand Down
17 changes: 12 additions & 5 deletions packages/model/vde_src_task_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
9 changes: 9 additions & 0 deletions packages/obsmanager/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
12 changes: 9 additions & 3 deletions packages/utils/rand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@
package utils

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestRand(t *testing.T) {
cases := [][]int64{
{3434102771992637744, 1523931518789473682},
{3434102771992637744, 1523931518789473682},
}

rand := NewRand(0)
for _, values := range cases {
r := rand.BytesSeed([]byte("reset"))
for _, v := range values {
assert.Equal(t, v, r.Int63())
}
}
}

0 comments on commit a430e4a

Please sign in to comment.