-
Notifications
You must be signed in to change notification settings - Fork 812
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
Allow optional pre BIP-37 behavior (the original satoshi protocol) #19
Conversation
tx.ts = tx.ts || self.ts; | ||
return tx; | ||
}); | ||
this.hashes = this.txs.map(function(tx) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should verify merkle root here
Alright, I wrote a function to build a merkle tree and verify the merkle root correctly (modeled after the bitcoind code). I also added some verification checks that bitcoind does on blocks (maybe we might want to do some of them on merkleblocks too?). Anyway, this all seems to work in practice. Let me know what you think. |
I can also revert all the CheckBlock stuff if you don't want it. |
|
||
Block.prototype._phash = function phash(p1begin, p1end, p2begin, p2end) { | ||
var pblank = ''; | ||
var hash1 = hash.sha256(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not utils.dsha256
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the same thing eventually. It now concatenates the two merkleTree hashes into utils.dsha256.
When I initially wrote it, I was essentially porting the awful c++ of bitcoind to javascript (to clarify: I'm not sure if I dislike the bitcoind codebase or just C++ in general), so it was confusing to say the least. The fuction looked too complex to be handled with just utils.dsha256. I was wrong.
I think the pull request is, more or less ready, but I kind of want to discuss usage. I've been messing around adding some code to Even more puzzling, I can't seem to get more than ~6000 blocks from my peers, even if I do a |
I definitely think there is something wrong with The only way I can get a full blockchain download is by creating my own version of With the former method, I'll usually get about 500-5000 unique blocks before bcoin hangs and stops requesting/receiving blocks completely. With the latter method, I can get a full blockchain download. I really can't figure it out. Does the Chain object need to be rewritten to accomodate these new features? |
Hm... it really shouldn't be. Unfortunately, I'm busy optimizing elliptic.js right now. Will look into it somewhere later. |
I understand. I'll continue to look into it. In the meantime, could you merge this branch? I think it's ready despite the Chain issue (I can still get a full blockchain download with it). Could you also merge the version packet pull request? I added a test like you said, and now the |
Allow optional pre BIP-37 behavior (the original satoshi protocol)
Awesome. Thank you. |
I realize bcoin is supposed to be used as an spv, but it wouldn't be that hard to add an option to allow a more traditional blockchain downloader. What do you think, @indutny? Is there anything I missed here?