From 5662a8423cc78b8d9aa58f2d0d936b9f88036f44 Mon Sep 17 00:00:00 2001 From: Eric Frias Date: Wed, 2 Sep 2015 17:25:52 -0400 Subject: [PATCH] Increase duration of message cache from two blocks (which in practice meant anything > 1 block) to 30 blocks, and move the constant to config.hpp --- libraries/net/include/graphene/net/config.hpp | 8 ++++++++ libraries/net/node.cpp | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libraries/net/include/graphene/net/config.hpp b/libraries/net/include/graphene/net/config.hpp index 3242658c..5273be0f 100644 --- a/libraries/net/include/graphene/net/config.hpp +++ b/libraries/net/include/graphene/net/config.hpp @@ -51,6 +51,14 @@ #define GRAPHENE_NET_MAXIMUM_QUEUED_MESSAGES_IN_BYTES (1024 * 1024) +/** + * When we receive a message from the network, we advertise it to + * our peers and save a copy in a cache were we will find it if + * a peer requests it. We expire out old items out of the cache + * after this number of blocks go by. + */ +#define GRAPHENE_NET_MESSAGE_CACHE_DURATION_IN_BLOCKS 30 + /** * We prevent a peer from offering us a list of blocks which, if we fetched them * all, would result in a blockchain that extended into the future. diff --git a/libraries/net/node.cpp b/libraries/net/node.cpp index 103eb54d..55005b86 100644 --- a/libraries/net/node.cpp +++ b/libraries/net/node.cpp @@ -120,7 +120,7 @@ namespace graphene { namespace net { class blockchain_tied_message_cache { private: - static const uint32_t cache_duration_in_blocks = 2; + static const uint32_t cache_duration_in_blocks = GRAPHENE_NET_MESSAGE_CACHE_DURATION_IN_BLOCKS; struct message_hash_index{}; struct message_contents_hash_index{};