Skip to content

Conversation

@dcousens
Copy link
Contributor

Resolves #279 .

The API right now is very simple, but provides the basic building blocks.
I'm not sure whether we should put merkle tree hashing in here or some where else.

Mostly this abstraction was created to be able to parse blocks, further functionality can be added when necessary?

@weilu thoughts?

@dcousens dcousens added this to the 1.3.0 milestone Oct 17, 2014
@dcousens
Copy link
Contributor Author

ping @weilu

@coveralls
Copy link

Coverage Status

Coverage increased (+0.09%) when pulling 8fe80b9 on block into 929d926 on master.

@sidazhang
Copy link
Contributor

the API LGTM

Is this going to be available before 3.0.0?

@weilu
Copy link
Contributor

weilu commented Nov 17, 2014

I'm trying to evaluate the API by using it: weilu/cb-blockr@c522315 @dcousens I'll have something for you by the end of this week. Sorry for the delay

@dcousens
Copy link
Contributor Author

No worries, look forward to your feedback.

webbtc.com provide a hex end point if you're looking for one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this function necessary? When I parse dates it's normally for display reasons, where local timezone would be more useful than UTC.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this problem be solved with documentation instead of exposing a function may or may not be useful to users?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind if we have getUTCDate or getLocalDate, but the important point is that the block.timestamp is UTC seconds, not your typical JS Date.
Personally, I find the UTC date useful because it outputs in your timezone anyway.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point is that this is a utility function that I expect to write myself as an app dev. I don't think it's relevant to block parsing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, this is a Javascript interface to a Block, so it seemed pertinent to provide a Javascript Date which deals with the .timestamp being stored in seconds correctly.
I'm open to other interpretations though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still conflicted on this. But I think I'm going to err on the side of minimizing possible user error by providing it, and if we don't see usage we can deprecate it later?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@weilu
Copy link
Contributor

weilu commented Nov 23, 2014

Looks good overall. When constructing a block by hand (as opposed to using the deserialization function), it wasn't immediately obvious that prevHash and merkleRoot are of type Buffer. I don't have a very good solution to this. Perhaps we can establish a convention where *Hash is always of type Buffer, and document it in readme?

@weilu
Copy link
Contributor

weilu commented Nov 23, 2014

Just a note: network.js pubKeyHash and scriptHash are integers

@dcousens
Copy link
Contributor Author

I think that is a good point about *Hash, I'm not against that always being a Buffer if appropriate. Though, I'm not sure what else you would have expected.

Just a note: network.js pubKeyHash and scriptHash are integers

What is the relevance here?

@weilu
Copy link
Contributor

weilu commented Nov 23, 2014

Those two will need to be renamed if we were to decide to go ahead with the *Hash => Buffer naming convention

@dcousens
Copy link
Contributor Author

Right. Not sure on that change.

@weilu
Copy link
Contributor

weilu commented Nov 24, 2014

@dcousens if you don't want to make any amendments go ahead merge it as-is. It's a small enough API can iterate on

@dcousens dcousens mentioned this pull request Nov 25, 2014
@dcousens dcousens modified the milestones: 1.4.0, 1.3.0 Nov 26, 2014
@kyledrake
Copy link
Contributor

+1 from me. This is an awesome feature to add to the library!

@dcousens
Copy link
Contributor Author

Rebased on HEAD

@coveralls
Copy link

Coverage Status

Coverage increased (+0.09%) when pulling b6b5b56 on block into 936f791 on master.

dcousens added a commit that referenced this pull request Nov 28, 2014
@dcousens dcousens merged commit 110cb86 into master Nov 28, 2014
@dcousens dcousens deleted the block branch November 28, 2014 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement block.js

6 participants