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) } }
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) dir, err := utils.GetCurrentDir() if err != nil { log.Fatal(err) } config, err := configparser.Read(dir + "/config.ini") if err != nil { log.Fatal(err) } configIni, err := config.Section("main") txType := "NewHolidays" txTime := "1426283713" blockData := make(map[string]string) var txSlice []string // hash txSlice = append(txSlice, "22cb812e53e22ee539af4a1d39b4596d") // type txSlice = append(txSlice, strconv.Itoa(int(TypeInt(txType)))) // time txSlice = append(txSlice, txTime) // user_id txSlice = append(txSlice, strconv.FormatInt(1, 10)) //start txSlice = append(txSlice, strconv.FormatInt(100000, 10)) //end txSlice = append(txSlice, strconv.FormatInt(4545, 10)) // sign txSlice = append(txSlice, "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111") blockData["block_id"] = strconv.FormatInt(185510, 10) blockData["time"] = txTime blockData["user_id"] = strconv.FormatInt(1, 10) //fmt.Println(txSlice) parser := new(dcparser.Parser) parser.DCDB = utils.NewDbConnect(configIni) parser.TxSlice = txSlice parser.BlockData = blockData /*for i:=0; i<10000; i++ { x := func() { stmt, err := parser.DCDB.Prepare(`INSERT INTO main_lock(lock_time,script_name) VALUES($1,$2)`) defer stmt.Close() if err!=nil { fmt.Println(err) } _, err = stmt.Exec(11111, "testblock_generator") if err!=nil { fmt.Println(err) } } x() //stmt, _ := parser.DCDB.Prepare(`INSERT INTO main_lock(lock_time,script_name) VALUES($1,$2)`) //fmt.Println(err) //defer stmt.Close() //_, _ = stmt.Exec(11111, "testblock_generator") //fmt.Println(err) //_, _ = parser.DCDB.Query("INSERT INTO main_lock(lock_time,script_name) VALUES($1,$2)", 11111, "testblock_generator") x2 := func() { row, err := parser.DCDB.Query("DELETE FROM main_lock WHERE script_name='testblock_generator'") defer row.Close() if err!=nil { fmt.Println(err) } } x2() //parser.DCDB.DbLock() //parser.DCDB.DbUnlock() //fmt.Println(i) }*/ fmt.Println() err = dcparser.MakeTest(parser, txType, hashesStart) if err != nil { fmt.Println("err", 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() /* var ptr reflect.Value var value reflect.Value //var finalMethod reflect.Value i := Test{Start: "start"} value = reflect.ValueOf(i) // if we start with a pointer, we need to get value pointed to // if we start with a value, we need to get a pointer to that value if value.Type().Kind() == reflect.Ptr { ptr = value value = ptr.Elem() } else { ptr = reflect.New(reflect.TypeOf(i)) temp := ptr.Elem() temp.Set(value) } fmt.Println(value) /* // check for method on value method := value.MethodByName("Finish") fmt.Println(method) // check for method on pointer method = ptr.MethodByName("Finish") fmt.Println(method)*/ }
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() }