
// getAppNetworkType provides functions to get the Seekia application network type.
// Examples of network types: "Mainnet" and "Testnet1".
// The Seekia client will only interface with and download content for the current app network type.

package getAppNetworkType

// Each network type is represented by a single byte
// 1 = Mainnet
// 2 = Testnet1

import "seekia/internal/globalSettings"
import "seekia/internal/helpers"

import "errors"


func GetAppNetworkType()(byte, error){

	exists, currentAppNetworkTypeString, err := globalSettings.GetSetting("AppNetworkType")	
	if (err != nil) { return 0, err }
	if (exists == false){
		// We default to Mainnet
		return 1, nil
	}

	currentAppNetworkType, err := helpers.ConvertNetworkTypeStringToByte(currentAppNetworkTypeString)
	if (err != nil) {
		return 0, errors.New("GlobalSettings malformed: Contains invalid AppNetworkType: " + currentAppNetworkTypeString)
	}

	return currentAppNetworkType, nil
}
