Ejemplo n.º 1
0
func main() {
	defaultAppPath := ombutil.AppDataDir("ombnode", false)
	var DBPath *string = flag.String(
		"pubrecpath",
		path.Join(defaultAppPath, "data", "testnet", "pubrecord.db"),
		"Path to the public record database",
	)

	var port *int = flag.Int(
		"port",
		8080,
		"Port to listen on.",
	)

	flag.Parse()

	db, err := pubrecdb.LoadDB(*DBPath)
	if err != nil {
		log.Fatal(err)
	}

	apiPrefix := "/api/"
	api := jsonapi.Handler(apiPrefix, db)

	mux := http.NewServeMux()
	mux.Handle(apiPrefix, api)
	mux.Handle("/", http.FileServer(http.Dir("./static")))

	host := "0.0.0.0:" + strconv.Itoa(*port)
	log.Printf("Server listening on: %s\n", host)

	log.Println(http.ListenAndServe(host, mux))
}
Ejemplo n.º 2
0
	"github.com/btcsuite/btcd/btcjson"
	"github.com/btcsuite/btcd/chaincfg"
	flags "github.com/btcsuite/go-flags"
	"github.com/soapboxsys/ombudslib/ombutil"
)

const (
	// unusableFlags are the command usage flags which this utility are not
	// able to use.  In particular it doesn't support websockets and
	// consequently notifications.
	unusableFlags = btcjson.UFWebsocketOnly | btcjson.UFNotification
)

var (
	ombudsNodeHome        = ombutil.AppDataDir("ombnode", false)
	btcdHomeDir           = filepath.Join(ombudsNodeHome, "node")
	retweeterHomeDir      = ombutil.AppDataDir("retweeters", false)
	defaultConfigFile     = filepath.Join(retweeterHomeDir, "serv.conf")
	defaultRPCServer      = "localhost"
	defaultRPCCertFile    = filepath.Join(ombudsNodeHome, "rpc.cert")
	defaultWalletCertFile = filepath.Join(ombudsNodeHome, "rpc.cert")
	defaultAccessToken    = filepath.Join(retweeterHomeDir, "token.json")
	defaultRelayUrl       = "http://relay.getombuds.org"
)

// config defines the configuration options for retweeter.
//
// See loadConfig for details on the configuration load process.
type config struct {
	ConfigFile  string `short:"C" long:"configfile" description:"Path to configuration file"`