Skip to content

Commit 1fdb04a

Browse files
committed
增加加速器
1 parent 226fc1f commit 1fdb04a

File tree

6 files changed

+25
-9
lines changed

6 files changed

+25
-9
lines changed

conf/nbs.db

0 Bytes
Binary file not shown.

src/main/java/io/nbs/client/ui/components/forms/LCFormLabel.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,8 @@ private void initComponents(){
4545
public void setVolumeText(String text){
4646
this.textArea.setText(text);
4747
}
48+
49+
public void setHorizontalAlignment(int horizontalAlignment){
50+
this.label.setHorizontalAlignment(horizontalAlignment);
51+
}
4852
}

src/main/java/io/nbs/client/ui/panels/im/IMFileActionListener.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import io.nbs.client.exceptions.FileTooLargeException;
88
import io.nbs.client.listener.IPFSFileUploader;
99
import io.nbs.client.ui.frames.MainFrame;
10+
import io.nbs.commons.helper.DateHelper;
1011
import io.nbs.commons.utils.DataSizeFormatUtil;
1112
import io.nbs.sdk.beans.PeerInfo;
1213
import io.nbs.sdk.prot.IPMParser;
@@ -46,7 +47,7 @@ public void actionPerformed(ActionEvent e) {
4647
this.jFileChooser.showDialog(Launcher.getContext().getCurrentFrame(),"选择");
4748
File selection = jFileChooser.getSelectedFile();
4849
if(selection==null)return;
49-
logger.info(selection.getAbsolutePath());
50+
logger.info("{}在{}分享了{}",MainFrame.getContext().getCurrentPeer().getNick(),DateHelper.currentTime(),selection.getAbsolutePath());
5051
if(selection.length()>200*1024*1024){
5152
JOptionPane.showMessageDialog(MainFrame.getContext(),"成功加入分享任务,由于文件较大需要稍等一会儿返回唯一串码.");
5253
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import io.nbs.client.ui.panels.ParentAvailablePanel;
2424
import io.nbs.client.ui.panels.manage.body.TipResultHashPanel;
2525
import io.nbs.client.vo.AttachmentDataDTO;
26+
import io.nbs.commons.helper.DateHelper;
2627
import io.nbs.commons.utils.ButtonIconUtil;
2728
import io.nbs.commons.utils.IconUtil;
2829
import io.nbs.sdk.page.PageModel;
@@ -184,10 +185,12 @@ private void searchHash(final String text){
184185
Multihash multihash1= Multihash.fromBase58(text);
185186
long start = System.currentTimeMillis();
186187
try {
188+
tipResultHashPanel.searchingFromIntelnet();
187189
Object o =ipfs.object.stat(multihash1);
188190
String json = JSONParser.toString(o);
189191
BlockStat stat = JSON.parseObject(json,BlockStat.class);
190192
long usedsecd = System.currentTimeMillis()-start;
193+
logger.info("TESTLOG>>>查找文件:{},用时{}",text,DateHelper.calcUsedTime(usedsecd));
191194
tipResultHashPanel.setBlkStat(stat,null,usedsecd);
192195
} catch (IOException e) {
193196
e.printStackTrace();

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package io.nbs.client.ui.panels.manage.body;
22

33
import com.alibaba.fastjson.JSON;
4-
import io.ipfs.api.IPFS;
5-
import io.ipfs.api.JSONParser;
6-
import io.ipfs.api.MerkleNode;
7-
import io.ipfs.api.ResData;
4+
import io.ipfs.api.*;
85
import io.ipfs.api.beans.blk.BlockStat;
96
import io.ipfs.api.beans.bw.BitSwap;
107
import io.ipfs.api.bitswap.BitSwapService;
@@ -160,11 +157,13 @@ public void startMonitor(String rhash,BlockStat stat){
160157
statusLabel.setText("浏览器打开,正在加载数据...");
161158

162159
new Thread(()->{
160+
int sec = 0;
163161
while (completeSize.get()<fsize){
164-
seconds += seconds;
162+
sec++;
165163
try {
166164
TimeUnit.SECONDS.sleep(1);
167-
timelabel.setText(seconds+"s");
165+
timelabel.setText(sec+"s");
166+
timelabel.updateUI();
168167
} catch (InterruptedException e) {
169168
e.printStackTrace();
170169
}
@@ -178,8 +177,8 @@ public void startMonitor(String rhash,BlockStat stat){
178177
generateHash(multihash);
179178
}).start();
180179

181-
boosterPined();
182180
monitorList();
181+
boosterPined();
183182
this.setVisible(true);
184183
}
185184

@@ -219,6 +218,9 @@ private void boosterPined(){
219218
long nl = completeSize.longValue()+stat.getCumulativeSize();
220219
completeSize.addAndGet(nl);
221220
ipfs.pin.add(multihash);
221+
byte[] data =ipfs.object.data(multihash);
222+
NamedStreamable.ByteArrayWrapper byteArrayWrapper = new NamedStreamable.ByteArrayWrapper(data);
223+
ipfs.add(byteArrayWrapper);
222224
Map blkMap = ipfs.block.stat(multihash);
223225
logger.info("{}>>block :{}",multihash.toBase58(),JSON.toJSON(blkMap));
224226
} catch (InterruptedException e) {

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ private void initComponents() {
122122
/**
123123
*
124124
*/
125-
searchUsed = new LCFormLabel("搜索到文件用时");
125+
searchUsed = new LCFormLabel("搜索到文件用时:");
126+
searchUsed.setHorizontalAlignment(JLabel.LEFT);
126127
operPanel = new JPanel();
127128
operPanel.setLayout(new FlowLayout(FlowLayout.RIGHT,20,5));
128129
operPanel.setVisible(false);
@@ -180,6 +181,9 @@ private void setListeners() {
180181
openBtn.addActionListener(new ActionListener() {
181182
@Override
182183
public void actionPerformed(ActionEvent e) {
184+
185+
186+
183187
BrowserOperationHelper.getInstance().openURL(hash58);
184188
}
185189
});
@@ -198,6 +202,8 @@ public void setHash(String hash){
198202
this.updateUI();
199203
}
200204

205+
206+
201207
public void setBlkStat(BlockStat stat,String errorMSG,long usedSecd){
202208
String timeUsed = DateHelper.calcUsedTime(usedSecd);
203209
searchUsed.setVolumeText(timeUsed);

0 commit comments

Comments
 (0)