Optional storing of expired and off-stream objects

- a new config file option, network/acceptmismatch, allows the inventory
to store objects that expired or are from a stream we're not
interested in. Having this on will prevent re-requesting objects that
other nodes incorrectly advertise. It defaults to false
This commit is contained in:
Peter Šurda 2017-06-02 15:43:35 +02:00
parent d75d920a68
commit 6044df5adf
Signed by untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87
2 changed files with 11 additions and 6 deletions

View File

@ -21,6 +21,7 @@ BMConfigDefaults = {
},
"inventory": {
"storage": "sqlite",
"acceptmismatch": False,
},
"zlib": {
'maxsize': 1048576

View File

@ -5,8 +5,6 @@ import math
import time
import socket
import struct
import random
import traceback
from addresses import calculateInventoryHash
from debug import logger
@ -278,8 +276,16 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
raise BMProtoExcessiveDataError()
self.object.checkProofOfWorkSufficient()
self.object.checkEOLSanity()
self.object.checkStream()
try:
self.object.checkEOLSanity()
except BMObjectExpiredError:
if not BMConfigParser().get("inventory", "acceptmismatch"):
raise
try:
self.object.checkStream()
except BMObjectUnwantedStreamError:
if not BMConfigParser().get("inventory", "acceptmismatch"):
raise
self.object.checkAlreadyHave()
if self.object.objectType == protocol.OBJECT_GETPUBKEY:
@ -448,9 +454,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
def handle_close(self, reason=None):
self.set_state("close")
if reason is None:
#logger.debug("%s:%i: closing, %s", self.destination.host, self.destination.port, ''.join(traceback.format_stack()))
logger.debug("%s:%i: closing", self.destination.host, self.destination.port)
#traceback.print_stack()
else:
logger.debug("%s:%i: closing, %s", self.destination.host, self.destination.port, reason)
AdvancedDispatcher.handle_close(self)