public TrackedPeer update(String event, ByteBuffer peerId,
			String hexPeerId, String ip, int port,
			long uploaded, long downloaded, long left)
		throws UnsupportedEncodingException {
		TrackedPeer peer;
		TrackedPeer.PeerState state = TrackedPeer.PeerState.UNKNOWN;

		if ("started".equals(event)) {
			peer = new TrackedPeer(this, ip, port, peerId);
			state = TrackedPeer.PeerState.STARTED;
			this.addPeer(peer);
		} else if ("stopped".equals(event)) {
			peer = this.removePeer(hexPeerId);
			state = TrackedPeer.PeerState.STOPPED;
		} else if ("completed".equals(event)) {
			peer = this.getPeer(hexPeerId);
			state = TrackedPeer.PeerState.COMPLETED;
		} else if (event == null) {
			peer = this.getPeer(hexPeerId);
			state = TrackedPeer.PeerState.STARTED;
		} else {
			throw new IllegalArgumentException("Unexpected announce event type!");
		}

		peer.update(state, uploaded, downloaded, left);
		return peer;
	}