-
Notifications
You must be signed in to change notification settings - Fork 276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement filterload, filteradd, filterclear, merkleblock messages #10
Comments
And "merkleblock" associated messages, and full BIP37 support as documented: https://github.com/bitcoin/bips/blob/master/bip-0037.mediawiki |
The bloom-filter that is needed to implement is located here: https://github.com/bitpay/bloom-filter We can extend it to include |
I've attempted some work here, not sure that I'm doing things the best way, so didn't want to PR it (and no |
Maybe not the best interface, but the current way is used easiest via: var BloomFilter = require('bloom-filter'),
Messages = require('bitcore-p2p').Messages;
var bf = BloomFilter.create(20, 0.01);
// Do your bloom filter inserts here
var msg = new Messages.FilterLoad().fromBloomFilter(bf); Short of using |
Awesome! Back in an earlier commit of bloom-filter: bitpay/bloom-filter@cde5fc6#diff-77a92250315fdf44b4ecf5b3fcf5fd3cL51 there are toBuffer and fromBuffer method that can be implemented here where BufferWriter/Reader are available, this way it is more portable (e.g. other situations where those methods may be needed, such as saving). var BloomFilter = require('bloom-filter');
BloomFilter.prototype.fromBuffer() = function fromBuffer() {
...
} Also many constants are available on Having a convenience method var msg = Messages.FilterLoad(bloomfilter.toBuffer()); I think the buffer dependency issue may be on the fact that it's in |
Thanks for the help. I didn't mean the |
I don't know if this interface makes sense: var msg = Messages.FilterLOad(bloomfilter.toBuffer()); Would we want the constructor signature to just take 1 param (a buffer for the whole Filter) or should it require the individual params, like function FilterLoad (data) { ... }
// Vs.
function FilterLoad(data, nHashFuncs, nTweak, nFlags) { ... } If I'm not a fan of interfaces that can take different params, or try to take different numbers of args and coerce that into other things, etc., unless its really necessary. |
FilterLoad should accept a 'filter' (which is an instance of BloomFilter), and fromBloomFilter isn't necessary. This is a common pattern for other messages. |
Merkle block is the only left, I think we need a MerkleBlock constructor and a method to verify that a transaction exist in a block: bitpay/bitcore#1082 |
@braydonf thanks for the help on this. Do you have any suggestions on an interface for the 'verify that a transaction exist in a block' interface piece? |
Commented on the associated PR, I think that sounds great. |
Awesome work! Thanks @throughnothing |
Original discussion here: bitpay/bitcore#115
The text was updated successfully, but these errors were encountered: