66-export ([start_link /0 ]).
77
88% % Supervisor callbacks
9- -export ([init /1 ]).
9+ -export ([init /1 , check_key / 0 ]).
1010
1111% % Helper macro for declaring children of supervisor
1212-define (CHILD (I , Type ), {I , {I , start_link , []}, permanent , 5000 , Type , [I ]}).
@@ -22,6 +22,28 @@ start_link() ->
2222% % Supervisor callbacks
2323% % ===================================================================
2424
25+ check_key () ->
26+ try
27+ Priv = nodekey :get_priv (),
28+ case tpecdsa :keytype (Priv ) of
29+ {priv , ed25519 } -> ok ;
30+ {priv , Type } ->
31+ throw ({keytype_not_supported ,Type })
32+ end ,
33+ Public = nodekey :get_pub (),
34+ logger :notice (" Starting up, pubkey is ~s " ,[hex :encode (Public )]),
35+ ok
36+ catch
37+ error :{badmatch ,undefined } ->
38+ {error ," privkey does not specified" };
39+ throw :Reason ->
40+ {error ,Reason };
41+ Ec :Ee ->
42+ logger :notice (" Node key error ~p :~p " ,[Ec ,Ee ]),
43+ {error ," privkey broken" }
44+ end .
45+
46+
2547init ([repl_sup ]) ->
2648 Sup = {_SupFlags = {simple_one_for_one , 5 , 10 },
2749 [
@@ -32,6 +54,13 @@ init([repl_sup]) ->
3254
3355init ([]) ->
3456 tpnode :reload (),
57+
58+ case check_key () of
59+ ok -> ok ;
60+ {error , Reason } ->
61+ throw (Reason )
62+ end ,
63+
3564 MandatoryServices = [ api ],
3665 VMHost = case application :get_env (tpnode ,vmaddr ,undefined ) of
3766 XHost when is_list (XHost ) ->
0 commit comments