iflen(self.data[24+lengthOfVarint+(32*i):56+lengthOfVarint+(32*i)])==32:#The length of an inventory hash should be 32. If it isn't 32 then the remote node is either badly programmed or behaving nefariously.
foriinrange(numberOfItemsInInv):#upon finishing dealing with an incoming message, the receiveDataThread will request a random object from the peer. This way if we get multiple inv messages from multiple peers which list mostly the same objects, we will make getdata requests for different random objects from the various peers.
iflen(self.data[24+lengthOfVarint+(32*i):56+lengthOfVarint+(32*i)])==32:#The length of an inventory hash should be 32. If it isn't 32 then the remote node is either badly programmed or behaving nefariously.
#Send a getdata message to our peer to request the object with the given hash
@ -1819,8 +1818,6 @@ class receiveDataThread(QThread):
pickle.dump(knownNodes,output)
output.close()
#I've commented out this code because it should be up to the newer node to decide whether their protocol version is incompatiable with the remote node's version.
'''if self.remoteProtocolVersion > 1:
print'The remote node''s protocol version is too new for this program to understand. Disconnecting. It is:',self.remoteProtocolVersion
@ -1839,7 +1836,7 @@ class receiveDataThread(QThread):
payload+=pack('>q',1)#bitflags of the services I offer.
payload+=pack('>q',int(time.time()))
payload+=pack('>q',1)#boolservices of remote connection. How can I even know this for sure? This is probably ignored by the remote host.
payload+=pack('>q',1)#boolservices offered by the remote node. This data is ignored by the remote host because how could We know what Their services are without them telling us?
payload+=pack('>H',self.PORT)#remote IPv6 and port
@ -2155,10 +2152,10 @@ class sqlThread(QThread):
# transmitdata is literally the data that was included in the Bitmessage pubkey message when it arrived, except for the 24 byte protocol header- ie, it starts with the POW nonce.
# time is the time that the pubkey was broadcast on the network same as with every other type of Bitmessage object.
# usedpersonally is set to "yes" if we have used the key personally. This keeps us from deleting it because we may want to reply to a message in the future. This field is not a bool because we may need more flexability in the future and it doesn't take up much more space anyway.
self.cur.execute('''CREATE TABLE pubkeys (hash blob, havecorrectnonce bool, transmitdata blob, time blob, usedpersonally text, UNIQUE(hash, havecorrectnonce, transmitdata) ON CONFLICT REPLACE)''')
self.cur.execute('''CREATE TABLE pubkeys (hash blob, havecorrectnonce bool, transmitdata blob, time blob, usedpersonally text, UNIQUE(hash, havecorrectnonce) ON CONFLICT REPLACE)''')
self.cur.execute('''CREATE TABLE knownnodes (timelastseen int, stream int, services blob, host blob, port blob, UNIQUE(host, stream, port) ON CONFLICT REPLACE)''')#This table isn't used in the program yet but I have a feeling that we'll need it.
self.cur.execute('''INSERT INTO subscriptions VALUES('Bitmessage new release/announcements','BM-BbkPSZbzPwpVcYZpU4yHwf9ZPEapN5Zx',1)''')
self.cur.execute('''INSERT INTO subscriptions VALUES('Bitmessage new releases/announcements','BM-BbkPSZbzPwpVcYZpU4yHwf9ZPEapN5Zx',1)''')
self.conn.commit()
print'Created messages database file'
exceptException,err:
@ -2168,6 +2165,7 @@ class sqlThread(QThread):
sys.stderr.write('ERROR trying to create database file (message.dat). Error message: %s\n'%str(err))
sys.exit()
#People running earlier versions of PyBitmessage do not have the usedpersonally field in their pubkeys table. Let's add it.
self.emit(SIGNAL("updateSentItemStatusByHash(PyQt_PyObject,PyQt_PyObject)"),toRipe,'Public key was requested earlier. Receiver must be offline. Will retry.')
else:
print'We already have the necessary public key.'
self.sendMsg(toRipe)
self.sendMsg(toRipe)#by calling this function, we are asserting that we already have the pubkey for toRipe
@ -3703,7 +3701,7 @@ class MyForm(QtGui.QMainWindow):
ifstatus=='versiontoohigh':
self.statusBar().showMessage('Error: The address version in '+toAddress+' is too high. Either you need to upgrade your Bitmessage software or your acquaintance is being clever.')
eliffromAddress=='':
self.statusBar().showMessage('Error: You must specify a From address. If you don''t have one, go to the ''Your Identities'' tab.')
self.statusBar().showMessage('Error: You must specify a From address. If you don\'t have one, go to the \'Your Identities\' tab.')