Skip to content
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

library function for api call "anchors" #130

Merged
merged 3 commits into from
Aug 18, 2020

Conversation

WhoSoup
Copy link
Member

@WhoSoup WhoSoup commented Oct 30, 2019

closes: #125

Adds two functions to the library: GetAnchors(hash string) and GetAnchorsByHeight(height int64) which cover the available parameters of the "anchors" endpoint: https://docs.factom.com/api#anchors

They return the response in the form of an Anchors struct. I ran into some difficulties as factomd only has ethereum anchors starting at height 202428 and before that it returns "false". Same for Bitcoin anchors in non-mainnet chains.

To avoid having to deal with unmarshalling into an interface{} and then painstakingly transferring the data to a struct, I opted to just find-replace "false" with "null" for the ethereum and bitcoin fields.

@sambarnes
Copy link
Contributor

sambarnes commented Oct 30, 2019

They return the response in the form of an Anchors struct. I ran into some difficulties as factomd only has ethereum anchors starting at height 202428 and before that it returns "false". Same for Bitcoin anchors in non-mainnet chains.

That is because the original code path that factomd parses anchors is on insertion of entries into the database. So that is the height that you did the upgrade to the ethereum anchor parsing version. But if you restart your node with --reparseanchorchains flag it will re-index all the anchors and give you all ethereum anchors before that height.

I agree it should have been a null instead of a bool there

@WhoSoup
Copy link
Member Author

WhoSoup commented Oct 30, 2019

But if you restart your node with --reparseanchorchains flag it will re-index all the anchors and give you all ethereum anchors before that height.

Ah, interesting. The custom unmarshaller is still necessary due to local chains not having anchors but that's good to know.

@ilzheev
Copy link

ilzheev commented Dec 18, 2019

@carryforward can we merge it into master while preparing the next release?

Copy link
Contributor

@PaulBernier PaulBernier left a comment

Choose a reason for hiding this comment

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

Can you add a test like you did for #140?

anchors.go Show resolved Hide resolved
@WhoSoup
Copy link
Member Author

WhoSoup commented Aug 17, 2020

Can you add a test like you did for #140?

unit test added

@PaulBernier PaulBernier merged commit 096274b into FactomProject:develop Aug 18, 2020
PaulBernier pushed a commit that referenced this pull request Dec 19, 2020
* anchors support

* allow request for height 0

* anchor unit test
PaulBernier pushed a commit that referenced this pull request Dec 19, 2020
* anchors support

* allow request for height 0

* anchor unit test
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.

4 participants