当前位置: 首页>>代码示例>>Java>>正文


Java Peer.blacklist方法代码示例

本文整理汇总了Java中nxt.peer.Peer.blacklist方法的典型用法代码示例。如果您正苦于以下问题:Java Peer.blacklist方法的具体用法?Java Peer.blacklist怎么用?Java Peer.blacklist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nxt.peer.Peer的用法示例。


在下文中一共展示了Peer.blacklist方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNextBlocks

import nxt.peer.Peer; //导入方法依赖的package包/类
private JSONArray getNextBlocks(Peer peer, long curBlockId) {

			JSONObject request = new JSONObject();
			request.put("requestType", "getNextBlocks");
			request.put("blockId", Convert.toUnsignedLong(curBlockId));
			JSONObject response = peer.send(JSON.prepareRequest(request));
			if (response == null) {
				return null;
			}

			JSONArray nextBlocks = (JSONArray) response.get("nextBlocks");
			if (nextBlocks == null) {
				return null;
			}
			// prevent overloading with blocks
			if (nextBlocks.size() > 1440) {
				Logger.logDebugMessage("Obsolete or rogue peer " + peer.getPeerAddress() + " sends too many nextBlocks, blacklisting");
				peer.blacklist();
				return null;
			}

			return nextBlocks;

		}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:25,代码来源:BlockchainProcessorImpl.java

示例2: processRequest

import nxt.peer.Peer; //导入方法依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest request)
        throws NxtException {
    JSONObject response = new JSONObject();
    
    String peerAddress = request.getParameter("peer");
    if (peerAddress == null) {
        return MISSING_PEER;
    }
    Peer peer = Peers.getPeer(peerAddress);
    if (peer == null) {
        //maybe add as new peer?
        return UNKNOWN_PEER;
    } else {
        peer.blacklist();
        response.put("done", true);
    }
    
    return response;
}
 
开发者ID:giannisKonst,项目名称:blockchain,代码行数:21,代码来源:BlacklistPeer.java

示例3: processRequest

import nxt.peer.Peer; //导入方法依赖的package包/类
@Override
JSONStreamAware processRequest(HttpServletRequest request)
        throws NxtException {
    JSONObject response = new JSONObject();
    
    String peerAddress = request.getParameter("peer");
    if (peerAddress == null) {
        return MISSING_PEER;
    }
    Peer peer = Peers.findOrCreatePeer(peerAddress, true);
    if (peer == null) {
        return UNKNOWN_PEER;
    } else {
        Peers.addPeer(peer);
        peer.blacklist("Manual blacklist");
        response.put("done", true);
    }
    
    return response;
}
 
开发者ID:BitcoinFullnode,项目名称:ROKOS-OK-Bitcoin-Fullnode,代码行数:21,代码来源:BlacklistPeer.java

示例4: getNextBlocks

import nxt.peer.Peer; //导入方法依赖的package包/类
private JSONArray getNextBlocks(Peer peer, long curBlockId) {

            JSONObject request = new JSONObject();
            request.put("requestType", "getNextBlocks");
            request.put("blockId", Convert.toUnsignedLong(curBlockId));
            JSONObject response = peer.send(JSON.prepareRequest(request));
            if (response == null) {
                return null;
            }

            JSONArray nextBlocks = (JSONArray) response.get("nextBlocks");
            if (nextBlocks == null) {
                return null;
            }
            // prevent overloading with blocks
            if (nextBlocks.size() > 720) {
                Logger.logDebugMessage("Obsolete or rogue peer " + peer.getPeerAddress() + " sends too many nextBlocks, blacklisting");
                peer.blacklist();
                return null;
            }

            return nextBlocks;

        }
 
开发者ID:Ziftr,项目名称:nxt,代码行数:25,代码来源:BlockchainProcessorImpl.java

示例5: getNextBlocks

import nxt.peer.Peer; //导入方法依赖的package包/类
private JSONArray getNextBlocks(Peer peer, Long curBlockId) {

            JSONObject request = new JSONObject();
            request.put("requestType", "getNextBlocks");
            request.put("blockId", Convert.toUnsignedLong(curBlockId));
            JSONObject response = peer.send(JSON.prepareRequest(request));
            if (response == null) {
                return null;
            }

            JSONArray nextBlocks = (JSONArray) response.get("nextBlocks");
            if (nextBlocks == null) {
                return null;
            }
            // prevent overloading with blocks
            if (nextBlocks.size() > 1440) {
                Logger.logDebugMessage("Obsolete or rogue peer " + peer.getPeerAddress() + " sends too many nextBlocks, blacklisting");
                peer.blacklist();
                return null;
            }

            return nextBlocks;

        }
 
开发者ID:aspnmy,项目名称:NasCoin,代码行数:25,代码来源:BlockchainProcessorImpl.java

示例6: getNextBlocks

import nxt.peer.Peer; //导入方法依赖的package包/类
private JSONArray getNextBlocks(Peer paramAnonymousPeer, Long paramAnonymousLong)
{
  JSONObject localJSONObject1 = new JSONObject();
  localJSONObject1.put("requestType", "getNextBlocks");
  localJSONObject1.put("blockId", Convert.toUnsignedLong(paramAnonymousLong));
  JSONObject localJSONObject2 = paramAnonymousPeer.send(JSON.prepareRequest(localJSONObject1));
  if (localJSONObject2 == null) {
    return null;
  }
  JSONArray localJSONArray = (JSONArray)localJSONObject2.get("nextBlocks");
  if (localJSONArray == null) {
    return null;
  }
  if (localJSONArray.size() > 1440)
  {
    Logger.logDebugMessage("Obsolete or rogue peer " + paramAnonymousPeer.getPeerAddress() + " sends too many nextBlocks, blacklisting");
    paramAnonymousPeer.blacklist();
    return null;
  }
  return localJSONArray;
}
 
开发者ID:stevedoe,项目名称:nxt-client,代码行数:22,代码来源:BlockchainProcessorImpl.java

示例7: getCommonBlockId

import nxt.peer.Peer; //导入方法依赖的package包/类
private long getCommonBlockId(Peer peer, long commonBlockId) {

			while (true) {
				JSONObject request = new JSONObject();
				request.put("requestType", "getNextBlockIds");
				request.put("blockId", Convert.toUnsignedLong(commonBlockId));
				JSONObject response = peer.send(JSON.prepareRequest(request));
				if (response == null) {
					return 0;
				}
				JSONArray nextBlockIds = (JSONArray) response.get("nextBlockIds");
				if (nextBlockIds == null || nextBlockIds.size() == 0) {
					return 0;
				}
				// prevent overloading with blockIds
				if (nextBlockIds.size() > 1440) {
					Logger.logDebugMessage("Obsolete or rogue peer " + peer.getPeerAddress() + " sends too many nextBlockIds, blacklisting");
					peer.blacklist();
					return 0;
				}

				for (Object nextBlockId : nextBlockIds) {
					long blockId = Convert.parseUnsignedLong((String) nextBlockId);
					if (! BlockDb.hasBlock(blockId)) {
						return commonBlockId;
					}
					commonBlockId = blockId;
				}
			}

		}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:32,代码来源:BlockchainProcessorImpl.java

示例8: getCommonBlockId

import nxt.peer.Peer; //导入方法依赖的package包/类
private long getCommonBlockId(Peer peer, long commonBlockId) {

            while (true) {
                JSONObject request = new JSONObject();
                request.put("requestType", "getNextBlockIds");
                request.put("blockId", Convert.toUnsignedLong(commonBlockId));
                JSONObject response = peer.send(JSON.prepareRequest(request));
                if (response == null) {
                    return 0;
                }
                JSONArray nextBlockIds = (JSONArray) response.get("nextBlockIds");
                if (nextBlockIds == null || nextBlockIds.size() == 0) {
                    return 0;
                }
                // prevent overloading with blockIds
                if (nextBlockIds.size() > 1440) {
                    Logger.logDebugMessage("Obsolete or rogue peer " + peer.getPeerAddress() + " sends too many nextBlockIds, blacklisting");
                    peer.blacklist();
                    return 0;
                }

                for (Object nextBlockId : nextBlockIds) {
                    long blockId = Convert.parseUnsignedLong((String) nextBlockId);
                    if (! BlockDb.hasBlock(blockId)) {
                        return commonBlockId;
                    }
                    commonBlockId = blockId;
                }
            }

        }
 
开发者ID:Ziftr,项目名称:nxt,代码行数:32,代码来源:BlockchainProcessorImpl.java

示例9: getCommonBlockId

import nxt.peer.Peer; //导入方法依赖的package包/类
private Long getCommonBlockId(Peer peer, Long commonBlockId) {

            while (true) {
                JSONObject request = new JSONObject();
                request.put("requestType", "getNextBlockIds");
                request.put("blockId", Convert.toUnsignedLong(commonBlockId));
                JSONObject response = peer.send(JSON.prepareRequest(request));
                if (response == null) {
                    return null;
                }
                JSONArray nextBlockIds = (JSONArray) response.get("nextBlockIds");
                if (nextBlockIds == null || nextBlockIds.size() == 0) {
                    return null;
                }
                // prevent overloading with blockIds
                if (nextBlockIds.size() > 1440) {
                    Logger.logDebugMessage("Obsolete or rogue peer " + peer.getPeerAddress() + " sends too many nextBlockIds, blacklisting");
                    peer.blacklist();
                    return null;
                }

                for (Object nextBlockId : nextBlockIds) {
                    Long blockId = Convert.parseUnsignedLong((String) nextBlockId);
                    if (! BlockDb.hasBlock(blockId)) {
                        return commonBlockId;
                    }
                    commonBlockId = blockId;
                }
            }

        }
 
开发者ID:aspnmy,项目名称:NasCoin,代码行数:32,代码来源:BlockchainProcessorImpl.java

示例10: getCommonBlockId

import nxt.peer.Peer; //导入方法依赖的package包/类
private Long getCommonBlockId(Peer paramAnonymousPeer, Long paramAnonymousLong)
{
  for (;;)
  {
    JSONObject localJSONObject1 = new JSONObject();
    localJSONObject1.put("requestType", "getNextBlockIds");
    localJSONObject1.put("blockId", Convert.toUnsignedLong(paramAnonymousLong));
    JSONObject localJSONObject2 = paramAnonymousPeer.send(JSON.prepareRequest(localJSONObject1));
    if (localJSONObject2 == null) {
      return null;
    }
    JSONArray localJSONArray = (JSONArray)localJSONObject2.get("nextBlockIds");
    if ((localJSONArray == null) || (localJSONArray.size() == 0)) {
      return null;
    }
    if (localJSONArray.size() > 1440)
    {
      Logger.logDebugMessage("Obsolete or rogue peer " + paramAnonymousPeer.getPeerAddress() + " sends too many nextBlockIds, blacklisting");
      paramAnonymousPeer.blacklist();
      return null;
    }
    for (Object localObject : localJSONArray)
    {
      Long localLong = Convert.parseUnsignedLong((String)localObject);
      if (!BlockDb.hasBlock(localLong)) {
        return paramAnonymousLong;
      }
      paramAnonymousLong = localLong;
    }
  }
}
 
开发者ID:stevedoe,项目名称:nxt-client,代码行数:32,代码来源:BlockchainProcessorImpl.java

示例11: getCommonMilestoneBlockId

import nxt.peer.Peer; //导入方法依赖的package包/类
private long getCommonMilestoneBlockId(Peer peer) {

			String lastMilestoneBlockId = null;

			while (true) {
				JSONObject milestoneBlockIdsRequest = new JSONObject();
				milestoneBlockIdsRequest.put("requestType", "getMilestoneBlockIds");
				if (lastMilestoneBlockId == null) {
					milestoneBlockIdsRequest.put("lastBlockId", blockchain.getLastBlock().getStringId());
				} else {
					milestoneBlockIdsRequest.put("lastMilestoneBlockId", lastMilestoneBlockId);
				}

				JSONObject response = peer.send(JSON.prepareRequest(milestoneBlockIdsRequest));
				if (response == null) {
					return 0;
				}
				JSONArray milestoneBlockIds = (JSONArray) response.get("milestoneBlockIds");
				if (milestoneBlockIds == null) {
					return 0;
				}
				if (milestoneBlockIds.isEmpty()) {
					return Genesis.GENESIS_BLOCK_ID;
				}
				// prevent overloading with blockIds
				if (milestoneBlockIds.size() > 20) {
					Logger.logDebugMessage("Obsolete or rogue peer " + peer.getPeerAddress() + " sends too many milestoneBlockIds, blacklisting");
					peer.blacklist();
					return 0;
				}
				if (Boolean.TRUE.equals(response.get("last"))) {
					peerHasMore = false;
				}
				for (Object milestoneBlockId : milestoneBlockIds) {
					long blockId = Convert.parseUnsignedLong((String) milestoneBlockId);
					if (BlockDb.hasBlock(blockId)) {
						if (lastMilestoneBlockId == null && milestoneBlockIds.size() > 1) {
							peerHasMore = false;
						}
						return blockId;
					}
					lastMilestoneBlockId = (String) milestoneBlockId;
				}
			}

		}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:47,代码来源:BlockchainProcessorImpl.java

示例12: getCommonMilestoneBlockId

import nxt.peer.Peer; //导入方法依赖的package包/类
private long getCommonMilestoneBlockId(Peer peer) {

            String lastMilestoneBlockId = null;

            while (true) {
                JSONObject milestoneBlockIdsRequest = new JSONObject();
                milestoneBlockIdsRequest.put("requestType", "getMilestoneBlockIds");
                if (lastMilestoneBlockId == null) {
                    milestoneBlockIdsRequest.put("lastBlockId", blockchain.getLastBlock().getStringId());
                } else {
                    milestoneBlockIdsRequest.put("lastMilestoneBlockId", lastMilestoneBlockId);
                }

                JSONObject response = peer.send(JSON.prepareRequest(milestoneBlockIdsRequest));
                if (response == null) {
                    return 0;
                }
                Logger.logDebugMessage("getCommonMilestoneBlockId() resp= "+response);
                JSONArray milestoneBlockIds = (JSONArray) response.get("milestoneBlockIds");
                if (milestoneBlockIds == null) {
                    return 0;
                }
                if (milestoneBlockIds.isEmpty()) {
                    return Nxt.getGenesisBlockId();
                }
                // prevent overloading with blockIds
                if (milestoneBlockIds.size() > 20) {
                    Logger.logDebugMessage("Obsolete or rogue peer " + peer.getPeerAddress() + " sends too many milestoneBlockIds, blacklisting");
                    peer.blacklist();
                    return 0;
                }
                if (Boolean.TRUE.equals(response.get("last"))) {
                    peerHasMore = false;
                }
                for (Object milestoneBlockId : milestoneBlockIds) {
                    long blockId = Convert.parseUnsignedLong((String) milestoneBlockId);
                    if (BlockDb.hasBlock(blockId)) {
                        if (lastMilestoneBlockId == null && milestoneBlockIds.size() > 1) {
                            peerHasMore = false;
                        }
                        return blockId;
                    }
                    lastMilestoneBlockId = (String) milestoneBlockId;
                }
            }

        }
 
开发者ID:giannisKonst,项目名称:blockchain,代码行数:48,代码来源:GetBlocksFromPeers.java

示例13: getCommonMilestoneBlockId

import nxt.peer.Peer; //导入方法依赖的package包/类
private long getCommonMilestoneBlockId(Peer peer) {

            String lastMilestoneBlockId = null;

            while (true) {
                JSONObject milestoneBlockIdsRequest = new JSONObject();
                milestoneBlockIdsRequest.put("requestType", "getMilestoneBlockIds");
                if (lastMilestoneBlockId == null) {
                    milestoneBlockIdsRequest.put("lastBlockId", blockchain.getLastBlock().getStringId());
                } else {
                    milestoneBlockIdsRequest.put("lastMilestoneBlockId", lastMilestoneBlockId);
                }

                JSONObject response = peer.send(JSON.prepareRequest(milestoneBlockIdsRequest));
                if (response == null) {
                    return 0;
                }
                JSONArray milestoneBlockIds = (JSONArray) response.get("milestoneBlockIds");
                if (milestoneBlockIds == null) {
                    return 0;
                }
                if (milestoneBlockIds.isEmpty()) {
                    return Genesis.GENESIS_BLOCK_ID;
                }
                // prevent overloading with blockIds
                if (milestoneBlockIds.size() > 20) {
                    Logger.logDebugMessage("Obsolete or rogue peer " + peer.getHost() + " sends too many milestoneBlockIds, blacklisting");
                    peer.blacklist("Too many milestoneBlockIds");
                    return 0;
                }
                if (Boolean.TRUE.equals(response.get("last"))) {
                    peerHasMore = false;
                }
                for (Object milestoneBlockId : milestoneBlockIds) {
                    long blockId = Convert.parseUnsignedLong((String) milestoneBlockId);
                    if (BlockDb.hasBlock(blockId)) {
                        if (lastMilestoneBlockId == null && milestoneBlockIds.size() > 1) {
                            peerHasMore = false;
                        }
                        return blockId;
                    }
                    lastMilestoneBlockId = (String) milestoneBlockId;
                }
            }

        }
 
开发者ID:BitcoinFullnode,项目名称:ROKOS-OK-Bitcoin-Fullnode,代码行数:47,代码来源:BlockchainProcessorImpl.java

示例14: getBlockIdsAfterCommon

import nxt.peer.Peer; //导入方法依赖的package包/类
private List<Long> getBlockIdsAfterCommon(final Peer peer, final long startBlockId, final boolean countFromStart) {
    long matchId = startBlockId;
    List<Long> blockList = new ArrayList<>(720);
    boolean matched = false;
    int limit = countFromStart ? 720 : 1440;
    while (true) {
        JSONObject request = new JSONObject();
        request.put("requestType", "getNextBlockIds");
        request.put("blockId", Long.toUnsignedString(matchId));
        request.put("limit", limit);
        JSONObject response = peer.send(JSON.prepareRequest(request));
        if (response == null) {
            return Collections.emptyList();
        }
        JSONArray nextBlockIds = (JSONArray) response.get("nextBlockIds");
        if (nextBlockIds == null || nextBlockIds.size() == 0) {
            break;
        }
        // prevent overloading with blockIds
        if (nextBlockIds.size() > limit) {
            Logger.logDebugMessage("Obsolete or rogue peer " + peer.getHost() + " sends too many nextBlockIds, blacklisting");
            peer.blacklist("Too many nextBlockIds");
            return Collections.emptyList();
        }
        boolean matching = true;
        int count = 0;
        for (Object nextBlockId : nextBlockIds) {
            long blockId = Convert.parseUnsignedLong((String)nextBlockId);
            if (matching) {
                if (BlockDb.hasBlock(blockId)) {
                    matchId = blockId;
                    matched = true;
                } else {
                    blockList.add(matchId);
                    blockList.add(blockId);
                    matching = false;
                }
            } else {
                blockList.add(blockId);
                if (blockList.size() >= 720) {
                    break;
                }
            }
            if (countFromStart && ++count >= 720) {
                break;
            }
        }
        if (!matching || countFromStart) {
            break;
        }
    }
    if (blockList.isEmpty() && matched) {
        blockList.add(matchId);
    }
    return blockList;
}
 
开发者ID:BitcoinFullnode,项目名称:ROKOS-OK-Bitcoin-Fullnode,代码行数:57,代码来源:BlockchainProcessorImpl.java

示例15: getCommonMilestoneBlockId

import nxt.peer.Peer; //导入方法依赖的package包/类
private long getCommonMilestoneBlockId(Peer peer) {

            String lastMilestoneBlockId = null;

            while (true) {
                JSONObject milestoneBlockIdsRequest = new JSONObject();
                milestoneBlockIdsRequest.put("requestType", "getMilestoneBlockIds");
                if (lastMilestoneBlockId == null) {
                    milestoneBlockIdsRequest.put("lastBlockId", blockchain.getLastBlock().getStringId());
                } else {
                    milestoneBlockIdsRequest.put("lastMilestoneBlockId", lastMilestoneBlockId);
                }

                JSONObject response = peer.send(JSON.prepareRequest(milestoneBlockIdsRequest));
                if (response == null) {
                    return 0;
                }
                JSONArray milestoneBlockIds = (JSONArray) response.get("milestoneBlockIds");
                if (milestoneBlockIds == null) {
                    return 0;
                }
                if (milestoneBlockIds.isEmpty()) {
                    return Genesis.GENESIS_BLOCK_ID;
                }
                // prevent overloading with blockIds
                if (milestoneBlockIds.size() > 20) {
                    Logger.logDebugMessage("Obsolete or rogue peer " + peer.getPeerAddress() + " sends too many milestoneBlockIds, blacklisting");
                    peer.blacklist();
                    return 0;
                }
                if (Boolean.TRUE.equals(response.get("last"))) {
                    peerHasMore = false;
                }
                for (Object milestoneBlockId : milestoneBlockIds) {
                    long blockId = Convert.parseUnsignedLong((String) milestoneBlockId);
                    if (BlockDb.hasBlock(blockId)) {
                        if (lastMilestoneBlockId == null && milestoneBlockIds.size() > 1) {
                            peerHasMore = false;
                        }
                        return blockId;
                    }
                    lastMilestoneBlockId = (String) milestoneBlockId;
                }
            }

        }
 
开发者ID:Ziftr,项目名称:nxt,代码行数:47,代码来源:BlockchainProcessorImpl.java


注:本文中的nxt.peer.Peer.blacklist方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。