115 lines
4.6 KiB
Erlang
115 lines
4.6 KiB
Erlang
-module(gmhc_config_schema).
|
|
-vsn("0.8.3").
|
|
|
|
-export([ schema/0
|
|
, to_json/0
|
|
, export/1 ]).
|
|
|
|
-import(gmconfig_schema_helpers,
|
|
[ str/1
|
|
, str/2
|
|
, pos_int/2
|
|
, int/2
|
|
, bool/2
|
|
, obj/1
|
|
, obj/2
|
|
, array/2
|
|
, schema_init/0
|
|
]).
|
|
|
|
-define(ACCOUNT_PATTERN, <<"^ak_[1-9A-HJ-NP-Za-km-z]*$">>).
|
|
-define(CONTRACT_PATTERN, <<"^ct_[1-9A-HJ-NP-Za-km-z]*$">>).
|
|
|
|
to_json() ->
|
|
json:encode(schema()).
|
|
|
|
export(ToFile) ->
|
|
case file:open(ToFile, [write]) of
|
|
{ok, Fd} ->
|
|
try ok = io:put_chars(Fd, json:format(schema(), #{indent => 4}))
|
|
after
|
|
file:close(Fd)
|
|
end;
|
|
{error, _} = Error ->
|
|
Error
|
|
end.
|
|
|
|
schema() ->
|
|
obj(schema_init(),
|
|
#{
|
|
network => str(#{ default => <<"mainnet">> })
|
|
, pubkey => str(#{pattern => ?ACCOUNT_PATTERN},
|
|
<<"Primary client pubkey">>)
|
|
, extra_pubkeys => array(#{ description =>
|
|
<<"Additional worker pubkeys, sharing rewards">>
|
|
, default => []
|
|
},
|
|
str(#{pattern => ?ACCOUNT_PATTERN}))
|
|
, type => str(#{ enum => [<<"worker">>, <<"monitor">>]
|
|
, default => <<"worker">>
|
|
, description => <<"monitor mode can be used to see if a pool is alive">>})
|
|
, pool => pool()
|
|
, pool_admin => pool_admin()
|
|
, workers => workers()
|
|
, cache_dir => str(#{description => <<"Location of cache, default is 'setup:data_dir()'">>})
|
|
, report => str(#{ enum => [<<"debug">>, <<"progress">>, <<"silent">>]
|
|
, default => <<"silent">>
|
|
, description => <<"Progress reporting">> })
|
|
}).
|
|
|
|
pool() ->
|
|
obj(#{
|
|
id => str(#{ pattern => ?CONTRACT_PATTERN},
|
|
<<"Pool contract id">>),
|
|
host => str(#{ default => <<"127.0.0.1">>
|
|
, example => <<"0.0.0.0">>
|
|
, description => <<"Hostname of hive server">> })
|
|
, port => pos_int(17888, <<"Hive server listen port">>)
|
|
}).
|
|
|
|
pool_admin() ->
|
|
obj(#{
|
|
url => str(#{ default => <<"https://test.gajumining.com/api/workers/{CLIENT_ID}">>
|
|
, description => <<"URL of Eureka worker api">> }),
|
|
default_per_network =>
|
|
obj(#{
|
|
testnet =>
|
|
str(#{default => <<"https://test.gajumining.com/api/workers/{CLIENT_ID}">>})
|
|
, mainnet =>
|
|
str(#{default => <<"https://gajumining.com/api/workers/{CLIENT_ID}">>})
|
|
})
|
|
}).
|
|
|
|
workers() ->
|
|
array(
|
|
#{default => [#{executable => <<"mean29-generic">>}],
|
|
description =>
|
|
<<"Definitions of workers' configurations. If no worker are configured one worker "
|
|
"is used as default, i.e. 'mean29-generic' executable without any extra args.">>},
|
|
obj(#{required => [<<"executable">>]},
|
|
#{executable =>
|
|
str(#{default => <<"mean29-generic">>,
|
|
description =>
|
|
<<"Executable binary of the worker. Can be a fully qualified path, \n"
|
|
"but the software may apply default logic to locate a plain basename.">>}),
|
|
extra_args =>
|
|
str(#{description => <<"Extra arguments to pass to the worker executable binary. "
|
|
"The safest choice is specifying no arguments i.e. empty string.">>,
|
|
default => <<>>}),
|
|
hex_encoded_header =>
|
|
bool(false, <<"Hexadecimal encode the header argument that is send to the worker executable. "
|
|
"CUDA executables expect hex encoded header.">>),
|
|
repeats =>
|
|
int(1, <<"Number of tries to do in each worker context - "
|
|
"WARNING: it should be set so the worker process "
|
|
"runs for 3-5s or else the node risk missing out on new micro blocks.">>),
|
|
instances =>
|
|
array(#{description =>
|
|
<<"Instances used by the worker in case of Multi-GPU mining. "
|
|
"Numbers on the configuration list represent GPU devices that are to "
|
|
"be addressed by the worker.">>,
|
|
minItems => 1,
|
|
example => [0,1,2,3]},
|
|
#{type => <<"integer">>})
|
|
})).
|