Esempio n. 1
0
func DbConn() *utils.DCDB {
	configIni_, err := config.NewConfig("ini", "config.ini")
	if err != nil {
		fmt.Println(err)
	}
	configIni, err := configIni_.GetSection("default")
	db := utils.DbConnect(configIni)
	return db
}
Esempio n. 2
0
func main() {

	f, err := os.OpenFile("dclog.txt", os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0777)
	defer f.Close()
	//log.SetOutput(f)
	log.SetOutput(io.MultiWriter(f, os.Stdout))
	log.SetFlags(log.LstdFlags | log.Lshortfile)

	txType := "Mining"
	txTime := "1406545931"
	userId := []byte("2")
	var blockId int64 = 123924

	var txSlice [][]byte
	// hash
	txSlice = append(txSlice, []byte("22cb812e53e22ee539af4a1d39b4596d"))
	// type
	txSlice = append(txSlice, utils.Int64ToByte(utils.TypeInt(txType)))
	// time
	txSlice = append(txSlice, []byte(txTime))
	// user_id
	txSlice = append(txSlice, userId)
	// promised_amount_id
	txSlice = append(txSlice, []byte(`26`))
	// amount
	txSlice = append(txSlice, []byte(`6`))
	// sign
	txSlice = append(txSlice, []byte("11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"))

	blockData := new(utils.BlockData)
	blockData.BlockId = blockId
	blockData.Time = utils.StrToInt64(txTime)
	blockData.UserId = utils.BytesToInt64(userId)

	dir, err := utils.GetCurrentDir()
	if err != nil {
		fmt.Println(err)
	}
	configIni_, err := config.NewConfig("ini", dir+"/config.ini")
	if err != nil {
		fmt.Println(err)
	}
	configIni, err := configIni_.GetSection("default")
	db := utils.DbConnect(configIni)

	// делаем снимок БД в виде хэшей до начала тестов
	hashesStart, err := tests_utils.AllHashes(db)

	err = tests_utils.MakeTest(txSlice, blockData, txType, hashesStart, db, "work")
	if err != nil {
		fmt.Println(err)
	}

}
Esempio n. 3
0
func main() {

	f, err := os.OpenFile("dclog.txt", os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0777)
	defer f.Close()
	log.SetOutput(f)
	log.SetFlags(log.LstdFlags | log.Lshortfile)

	txType := "NewPct"
	txTime := "1426283713"
	userId := []byte("1")

	var txSlice [][]byte
	// hash
	txSlice = append(txSlice, []byte("22cb812e53e22ee539af4a1d39b4596d"))
	// type
	txSlice = append(txSlice, utils.Int64ToByte(TypeInt(txType)))
	// time
	txSlice = append(txSlice, []byte(txTime))
	// user_id
	txSlice = append(txSlice, userId)
	//new_pct
	txSlice = append(txSlice, []byte(`{"1":{"miner_pct":"0.0000000044318","user_pct":"0.0000000027036"},"72":{"miner_pct":"0.0000000047610","user_pct":"0.0000000029646"}}`))
	// sign
	txSlice = append(txSlice, []byte("11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"))

	blockData := new(utils.BlockData)
	blockData.BlockId = 1200
	blockData.Time = utils.StrToInt64(txTime)
	blockData.UserId = 1

	dir, err := utils.GetCurrentDir()
	if err != nil {
		fmt.Println(err)
	}
	configIni_, err := config.NewConfig("ini", dir+"/config.ini")
	if err != nil {
		fmt.Println(err)
	}
	configIni, err := configIni_.GetSection("default")
	db := utils.DbConnect(configIni)
	parser := new(dcparser.Parser)
	parser.DCDB = db
	parser.TxSlice = txSlice
	parser.BlockData = blockData

	// делаем снимок БД в виде хэшей до начала тестов
	hashesStart, err := parser.AllHashes()

	err = dcparser.MakeTest(parser, txType, hashesStart)
	if err != nil {
		fmt.Println(err)
	}
	//go daemons.Testblock_is_ready()

	//parser.Db.HashTableData("holidays", "", "")
	//HashTableData(parser.Db.DB,"holidays", "", "")
	//hashes, err := parser.Db.AllHashes()
	utils.CheckErr(err)
	//fmt.Println(hashes)
	fmt.Println()

}