3 Initialize DHT local node ID from file.
4 Restore DHT routing table from file.
5 Save DHT routing table on exit and periodically.
11 uses NetAddr
,ServerLoop
,DHT
,SysUtils
,Store1
;
13 const ndfn
='nodes.dat';
14 const idfn
='idhash.txt';
17 var nd
: FILE of tPeerPub
;
26 dht
.GetNextNode(nnp
,nni
,node
);
27 if node
.addr
.isNil
then break
;
28 writeln('dhtPersist: save ',string(node
.addr
));
38 var nd
: FILE of tPeerPub
;
46 writeln('dhtPersist: can not open state file ',ndfn
);
48 {need to read the file backwards}
51 for pos
:=pos
-1 downto 0 do begin
54 writeln('dhtPersist: load ',string(node
.addr
));
68 writeln('dhtPersist: can not open id file ',idfn
);
71 writeln('dhtPersist: nodeID ',line
);
93 procedure t
.doPeriodic
;
96 Shedule(40000,@doPeriodic
);
102 Shedule(1200,@doSoon
);
103 Shedule(40000,@doPeriodic
);
104 pot
:=ServerLoop
.OnTerminate
;
105 ServerLoop
.OnTerminate
:=@doLast
;