From 0cae253fd4ca46ea8d8c86a83fd440b5e56e99ef Mon Sep 17 00:00:00 2001 From: rico666 Date: Wed, 2 Jan 2019 17:12:14 +0100 Subject: [PATCH] Test API "This request is only accepted using POST!" Fix --- src/brs/http/APITag.java | 2 +- src/brs/http/APITestServlet.java | 2 +- src/brs/http/GetMyPeerInfo.java | 2 +- src/brs/peer/Peers.java | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/brs/http/APITag.java b/src/brs/http/APITag.java index e45ab21f2..3132fa5c3 100644 --- a/src/brs/http/APITag.java +++ b/src/brs/http/APITag.java @@ -5,7 +5,7 @@ public enum APITag { ACCOUNTS("Accounts"), ALIASES("Aliases"), AE("Asset Exchange"), CREATE_TRANSACTION("Create Transaction"), BLOCKS("Blocks"), DGS("Digital Goods Store"), FORGING("Forging"), INFO("Server Info"), MESSAGES("Messages"), MINING("Mining"), TRANSACTIONS("Transactions"), TOKENS("Tokens"), VS("Voting System"), AT("Automated Transaction"), - FEES("Fees"), UTILS("Utils"), DEBUG("Debug"); + FEES("Fees"), UTILS("Utils"), DEBUG("Debug"), PEER_INFO("Server Peer Info"); private final String displayName; diff --git a/src/brs/http/APITestServlet.java b/src/brs/http/APITestServlet.java index 2d1e742c2..b2b467d4d 100644 --- a/src/brs/http/APITestServlet.java +++ b/src/brs/http/APITestServlet.java @@ -55,7 +55,7 @@ public class APITestServlet extends HttpServlet { + " }\n" + " $.ajax({\n" + " url: url,\n" - + " type: 'GET',\n" + + " type: 'POST',\n" + " })\n" + " .done(function(result) {\n" + " var resultStr = JSON.stringify(JSON.parse(result), null, 4);\n" diff --git a/src/brs/http/GetMyPeerInfo.java b/src/brs/http/GetMyPeerInfo.java index b3bf78716..dc40319c0 100644 --- a/src/brs/http/GetMyPeerInfo.java +++ b/src/brs/http/GetMyPeerInfo.java @@ -12,7 +12,7 @@ public final class GetMyPeerInfo extends APIServlet.APIRequestHandler { private final TransactionProcessor transactionProcessor; public GetMyPeerInfo(BlockchainProcessor blockchainProcessor, TransactionProcessor transactionProcessor) { - super(new APITag[]{APITag.INFO}); + super(new APITag[]{APITag.PEER_INFO}); this.blockchainProcessor = blockchainProcessor; this.transactionProcessor = transactionProcessor; } diff --git a/src/brs/peer/Peers.java b/src/brs/peer/Peers.java index 7a01c9572..0aeacca39 100644 --- a/src/brs/peer/Peers.java +++ b/src/brs/peer/Peers.java @@ -834,7 +834,8 @@ private static void feedPeer(Peer peer, Function> foodDi if(response != null && response.get("error") == null) { doneFeedingLog.accept(peer, transactionsToSend); } else { - logger.warn("Error feeding {} transactions: {} error: {}", peer.getPeerAddress(), transactionsToSend.stream().map(t -> t.getId()).collect(Collectors.toList()), response); + logger.warn("Error feeding {} transactions: {} error: {} - removing peer for now.", peer.getPeerAddress(), transactionsToSend.stream().map(t -> t.getId()).collect(Collectors.toList()), response); + peer.remove(); } } else { logger.trace("No need to feed {}", peer.getPeerAddress());