Closed throughnothing closed 9 years ago
Huh, I didn't think this one would reduce coverage.
Updated the interface for FilterLoad()
to just take a filter
, got rid of the constants, and used bloom-filter
for them, and got rid of fromBloomFilter()
.
We're going to need some additional methods on BloomFilter to implement isRelevantAndUpdate
as well as toBuffer
and fromBuffer
as part of having a standard interface for bitcore objects, so I think it makes sense to have the buffer conversion there.
For example we can extend bloom-filter in bitcore-p2p:
lib/bloomfilter.js
:
var BloomFilter = require('bloom-filter');
BloomFilter.prototype.fromBuffer = function fromBuffer() {
...
};
BloomFilter.prototype.toBuffer = function toBuffer() {
...
};
BloomFilter.prototype.isRelevantAndUpdate = function isRelevantAndUpdate(transaction) {
var hash = transaction.hash;
// we can implement this later
};
// etc.
And then require it in messages:
lib/messages.js
:
var BloomFilter = require('./bloomfilter');
FilterLoad.prototype.fromBuffer = function fromBuffer(buffer) {
this.filter = BloomFilter.fromBuffer(buffer);
return this;
}
Additionally the checks, such as MAX_HASH_FUNCS are already made in BloomFilter, so we don't need to check it twice.
Looks good, we can implement an extended bloomfilter later if its needed.
The last commit makes filter
required on FilterLoad
, but I'm not sure I like it.
Okay, so I think it makes sense to instantiate where filter would be empty. And that way fromBuffer can instantiate an instance of BloomFilter.
I also noticed this isn't actually working on my client, even though the tests pass. It's currently sending an invalid message. Will figure out why.
A few more tests: https://github.com/throughnothing/bitcore-p2p/pull/1
LGTM
generally LGTM. Will review in depth tomorrow. Thanks a lot for the awesome contrib! :)
ACK, sans minor comment
Fixed the _.isUndefined()
issue, I think this is good to go now.
This relates to issue #10