Skip to content

Commit

Permalink
Optional storing of expired and off-stream objects
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
PeterSurda committed Jun 2, 2017
1 parent d75d920 commit 6044df5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/bmconfigparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
},
"inventory": {
"storage": "sqlite",
"acceptmismatch": False,
},
"zlib": {
'maxsize': 1048576
Expand Down
16 changes: 10 additions & 6 deletions src/network/bmproto.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import time
import socket
import struct
import random
import traceback

from addresses import calculateInventoryHash
from debug import logger
Expand Down Expand Up @@ -278,8 +276,16 @@ def bm_command_object(self):
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:
Expand Down Expand Up @@ -448,9 +454,7 @@ def assembleAddr(peerList):
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)

0 comments on commit 6044df5

Please sign in to comment.