⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 remoteposition.java

📁 这是一个基于java编写的torrent的P2P源码
💻 JAVA
字号:
package com.aelitis.azureus.vivaldi.ver2;

import java.io.DataInputStream;
import java.io.IOException;

import com.aelitis.azureus.core.dht.netcoords.DHTNetworkPosition;

import edu.harvard.syrah.nc.Coordinate;

/*
 * The DHTNetworkPosition implementation for a remote node.
 */
class RemotePosition extends SyrahPosition {
	private Coordinate coords;
	private float error;
	private long age;
  
	protected RemotePosition(DataInputStream dis) throws IOException {
		coords = new Coordinate(VivaldiV2PositionProvider.NUM_DIMS, dis);
		error = dis.readFloat();
		age = dis.readLong();
	}

	public Coordinate getCoords() {
		return coords;
	}

       // Because we are currently sending only one coordinate over the wire,
       // only got one to reply with.
       // In future might want to send both and use stable coord for routing table
	public Coordinate getStableCoords() {
		return coords;
	}


	public float getError() {
		return error;
	}

  public long getAge () {
    return age;
  }
  
	public float estimateRTT(DHTNetworkPosition other) {
		SyrahPosition sp = (SyrahPosition) other;
    if (Float.isNaN(error) || Float.isNaN(sp.getError())) return Float.NaN;
    return (float) coords.distanceToNonOriginCoord(sp.getCoords());
	}

	public void update(byte[] other_id, DHTNetworkPosition other, float rtt) {
		// log error
		VivaldiV2PositionProvider.doLog("method update invoked on a remote position");
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -