Skip to content

Commit 0c354c3

Browse files
committed
增加加速器
1 parent 384b1bb commit 0c354c3

File tree

3 files changed

+28
-21
lines changed

3 files changed

+28
-21
lines changed

src/main/java/io/nbs/client/ui/panels/manage/MMBodyPanel.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,10 @@ private void setListeners() {
107107
*/
108108
public void showPanel(MMNames who){
109109
if(who==MMNames.TIP){
110-
MMMonitPanel.CtrlSign = false;
111-
}else {
112110
MMMonitPanel.CtrlSign = true;
111+
}else {
112+
tipResultHashPanel.hideMMMonitor();
113+
MMMonitPanel.CtrlSign = false;
113114
}
114115
cardLayout.show(cardPanel,who.name());
115116
}

src/main/java/io/nbs/client/ui/panels/manage/body/MMMonitPanel.java

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -156,19 +156,7 @@ public void startMonitor(String rhash,BlockStat stat){
156156
Multihash multihash = Multihash.fromBase58(stat.getHash());
157157

158158

159-
new Thread(()->{
160-
int sec = 0;
161-
while (completeSize.get()<fsize){
162-
sec++;
163-
try {
164-
TimeUnit.SECONDS.sleep(1);
165-
timelabel.setText(sec+"s");
166-
timelabel.updateUI();
167-
} catch (InterruptedException e) {
168-
e.printStackTrace();
169-
}
170-
}
171-
}).start();
159+
172160

173161

174162
blkmap.clear();
@@ -206,10 +194,8 @@ private void generateHash(Multihash multihash){
206194
*
207195
*/
208196
public void boosterPined(){
209-
if(CtrlSign)return;
210197
new Thread(()->{
211-
while (completeSize.get()<fsize){
212-
CtrlSign = true;
198+
while (CtrlSign){
213199
try {
214200
Multihash multihash = pinedBooster.take();
215201

@@ -231,20 +217,35 @@ public void boosterPined(){
231217
e.printStackTrace();
232218
}
233219
}
234-
CtrlSign = false;
235220
}).start();
236221
}
237222

238223
/**
239224
*
240225
*/
241226
public void monitorList(){
227+
this.setVisible(true);
228+
new Thread(()->{
229+
int sec = 0;
230+
statusLabel.setText("浏览器打开,正在加载数据...");
231+
while (CtrlSign){
232+
sec++;
233+
timelabel.setText(sec+"s");
234+
timelabel.updateUI();
235+
try {
236+
TimeUnit.SECONDS.sleep(1);
237+
} catch (InterruptedException e) {
238+
e.printStackTrace();
239+
}
240+
}
241+
}).start();
242242

243243
new Thread(()->{
244-
while (!CtrlSign){
244+
while (CtrlSign){
245245
ResData<BitSwap> resData = bitSwapService.getBitSwapStat();
246246
if(resData.getCode()==0){
247-
statusLabel.setText("浏览器打开,正在加载数据...");
247+
248+
248249
BitSwap bitSwap = resData.getData();
249250
if(bitSwap!=null&&bitSwap.getWantlist().size()>0){
250251
wantListPanel.removeAll();
@@ -265,6 +266,7 @@ public void mouseEntered(MouseEvent e) {
265266
super.addMouseListener(adapter);
266267
}
267268
});
269+
268270
wantListPanel.updateUI();
269271
}
270272

src/main/java/io/nbs/client/ui/panels/manage/body/TipResultHashPanel.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,4 +279,8 @@ private void pinedHash(){
279279
public MerkleNode getLinks() {
280280
return null;
281281
}
282+
283+
public void hideMMMonitor(){
284+
monitPanel.setVisible(false);
285+
}
282286
}

0 commit comments

Comments
 (0)