func createFullServer(dbuser string, dbpass string, dbhost string, dbport uint16, coinList []*coinparam.Params, serverhost string, serverport uint16, privkey *koblitz.PrivateKey, authrpc bool) (ocxServer *cxserver.OpencxServer, offChan chan bool, err error) {

	// Create db connection
	var db *cxdbsql.DB
	if db, err = cxdbsql.CreateDBConnection(dbuser, dbpass, dbhost, dbport); err != nil {
		err = fmt.Errorf("Error initializing Database: \n%s", err)
		return
	}

	// Setup DB Client
	if err = db.SetupClient(coinList); err != nil {
		err = fmt.Errorf("Error setting up sql client: \n%s", err)
		return
	}

	// first add closeDB to the stack of things we're deferring until we're out of the scope of this function
	// functionCloser(closeFunc, db.DBHandler.Close)

	// Anyways, here's where we set the server
	ocxServer = cxserver.InitServer(db, "", serverport, coinList)

	key := new([32]byte)
	copy(key[:], privkey.Serialize())

	// Check that the private key exists and if it does, load it
	if err = ocxServer.SetupServerKeys(key); err != nil {
		err = fmt.Errorf("Error setting up server keys: \n%s", err)
	}

	// Register RPC Commands and set server
	rpc1 := new(cxrpc.OpencxRPC)
	rpc1.OffButton = make(chan bool, 1)
	rpc1.Server = ocxServer

	if !authrpc {
		// this tells us when the rpclisten is done
		doneChan := make(chan bool, 1)
		logging.Infof(" === will start to listen on rpc ===")
		go cxrpc.RPCListenAsync(doneChan, rpc1, serverhost, serverport)
	} else {

		privkey, _ := koblitz.PrivKeyFromBytes(koblitz.S256(), key[:])
		// this tells us when the rpclisten is done
		doneChan := make(chan bool, 1)
		logging.Infof(" === will start to listen on noise-rpc ===")
		go cxrpc.NoiseListenAsync(doneChan, privkey, rpc1, serverhost, serverport)
	}

	offChan = rpc1.OffButton
	// // create function and add it to closing stack that we made ourselves.
	// closeListeners := func() (err error) {
	// 	// lol just turn it off
	// 	rpc1.OffButton <- true
	// 	return
	// }
	// functionCloser(closeFunc, closeListeners)

	return
}
// createFullServer creates a server after starting the database with a bunch of parameters
createFullServer creates a server after starting the database with a bunch of parameters
// createFullServer creates a server after starting the database with a bunch of parameters
func createFullServer(dbuser string, dbpass string, dbhost string, dbport uint16, coinList []*coinparam.Params, serverhost string, serverport uint16, privkey *koblitz.PrivateKey, authrpc bool) (ocxServer *cxserver.OpencxServer, offChan chan bool, err error) {
	var db *cxdbsql.DB
	if db, err = cxdbsql.CreateDBConnection(dbuser, dbpass, dbhost, dbport); err != nil {
		err = fmt.Errorf("Error initializing Database: \n%s", err)
		return
	}
	if err = db.SetupClient(coinList); err != nil {
		err = fmt.Errorf("Error setting up sql client: \n%s", err)
		return
	}
	ocxServer = cxserver.InitServer(db, "", serverport, coinList)
	key := new([32]byte)
	copy(key[:], privkey.Serialize())
	if err = ocxServer.SetupServerKeys(key); err != nil {
		err = fmt.Errorf("Error setting up server keys: \n%s", err)
	}
	rpc1 := new(cxrpc.OpencxRPC)
	rpc1.OffButton = make(chan bool, 1)
	rpc1.Server = ocxServer
	if !authrpc {
		doneChan := make(chan bool, 1)
		logging.Infof(" === will start to listen on rpc ===")
		go cxrpc.RPCListenAsync(doneChan, rpc1, serverhost, serverport)
	} else {
		privkey, _ := koblitz.PrivKeyFromBytes(koblitz.S256(), key[:])
		doneChan := make(chan bool, 1)
		logging.Infof(" === will start to listen on noise-rpc ===")
		go cxrpc.NoiseListenAsync(doneChan, privkey, rpc1, serverhost, serverport)
	}
	offChan = rpc1.OffButton
	return
}
func createFullServer ( dbuser string , dbpass string , dbhost string , dbport uint16 , coinList [ ] * coinparam . Params , serverhost string , serverport uint16 , privkey * koblitz . PrivateKey , authrpc bool ) ( ocxServer * cxserver . OpencxServer , offChan chan bool , err error ) { var db * cxdbsql . DB if db , err = cxdbsql . CreateDBConnection ( dbuser , dbpass , dbhost , dbport ) ; err != nil { err = fmt . Errorf ( " \n " , err ) return } if err = db . SetupClient ( coinList ) ; err != nil { err = fmt . Errorf ( " \n " , err ) return } ocxServer = cxserver . InitServer ( db , " " , serverport , coinList ) key := new ( [ 32 ] byte ) copy ( key [ : ] , privkey . Serialize ( ) ) if err = ocxServer . SetupServerKeys ( key ) ; err != nil { err = fmt . Errorf ( " \n " , err ) } rpc1 := new ( cxrpc . OpencxRPC ) rpc1 . OffButton = make ( chan bool , 1 ) rpc1 . Server = ocxServer if ! authrpc { doneChan := make ( chan bool , 1 ) logging . Infof ( " " ) go cxrpc . RPCListenAsync ( doneChan , rpc1 , serverhost , serverport ) } else { privkey , _ := koblitz . PrivKeyFromBytes ( koblitz . S256 ( ) , key [ : ] ) doneChan := make ( chan bool , 1 ) logging . Infof ( " " ) go cxrpc . NoiseListenAsync ( doneChan , privkey , rpc1 , serverhost , serverport ) } offChan = rpc1 . OffButton return }
createFullServer creates a server after starting the database with a bunch of parameters
createFullServer creates a server after starting the database with a bunch of parameters
// Create db connection // Setup DB Client // first add closeDB to the stack of things we're deferring until we're out of the scope of this function // functionCloser(closeFunc, db.DBHandler.Close) // Anyways, here's where we set the server // Check that the private key exists and if it does, load it // Register RPC Commands and set server // this tells us when the rpclisten is done // this tells us when the rpclisten is done // // create function and add it to closing stack that we made ourselves. // closeListeners := func() (err error) { // 	// lol just turn it off // 	rpc1.OffButton <- true // 	return // } // functionCloser(closeFunc, closeListeners)