Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upConsensus blocks api #2046
Conversation
S-anasol
added some commits
Jun 25, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
S-anasol
Jun 28, 2017
Contributor
Response (block) example: https://gist.github.com/S-anasol/3fb462145ee8c13f16cf80f081b5642a
|
Response (block) example: https://gist.github.com/S-anasol/3fb462145ee8c13f16cf80f081b5642a |
S-anasol
added some commits
Jun 28, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
S-anasol
Jul 2, 2017
Contributor
No commets?
let me know if you want some additions.
But this is must have and useful
https://explorer.siahub.info/ powered by this PR
|
No commets? But this is must have and useful |
| @@ -162,6 +162,7 @@ func New(requiredUserAgent string, requiredPassword string, cs modules.Consensus | ||
| if api.cs != nil { | ||
| router.GET("/consensus", api.consensusHandler) | ||
| router.POST("/consensus/validate/transactionset", api.consensusValidateTransactionsetHandler) | ||
| router.GET("/consensus/blocks/:height", api.consensusBlocksHandler) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
DavidVorick
Aug 1, 2017
Member
Wondering if we should let the user request by both height and id, or if just height is enough
DavidVorick
Aug 1, 2017
Member
Wondering if we should let the user request by both height and id, or if just height is enough
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
S-anasol
Aug 1, 2017
Contributor
since at zero point we dont have any hash - easier way to get first data is just height of block.
Optionally ofc can be queried by hash, but i see no need for me.
S-anasol
Aug 1, 2017
Contributor
since at zero point we dont have any hash - easier way to get first data is just height of block.
Optionally ofc can be queried by hash, but i see no need for me.
| @@ -19,6 +21,55 @@ type ConsensusGET struct { | ||
| Difficulty types.Currency `json:"difficulty"` | ||
| } | ||
| type ConsensusFileContract struct { |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
| RevisionNumber uint64 `json:"revisionnumber"` | ||
| } | ||
| type ConsensusFileContractRevision struct { |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
| NewUnlockHash types.UnlockHash `json:"newunlockhash"` | ||
| } | ||
| type ConsensusTransaction struct { |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
| SiacoinInputs map[string]types.SiacoinInput `json:"siacoininputs"` | ||
| SiacoinOutputs map[string]types.SiacoinOutput `json:"siacoinoutputs"` | ||
| FileContracts map[string]ConsensusFileContract `json:"filecontracts"` | ||
| FileContractRevisions map[string]ConsensusFileContractRevision `json:"filecontractrevisions"` |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
DavidVorick
Aug 1, 2017
Member
Why are these newly defined types instead of just using the types package?
DavidVorick
Aug 1, 2017
Member
Why are these newly defined types instead of just using the types package?
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
S-anasol
Aug 1, 2017
Contributor
need this for child maps with hash as key
ValidProofOutputs map[string]types.SiacoinOutput
but actually not sure that we need these output/input hashes, it should be in blockchain in usual way too as simple out/in not in contract?
S-anasol
Aug 1, 2017
Contributor
need this for child maps with hash as key
ValidProofOutputs map[string]types.SiacoinOutput
but actually not sure that we need these output/input hashes, it should be in blockchain in usual way too as simple out/in not in contract?
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
DavidVorick
Aug 1, 2017
Member
Is there any particular reason that you can't just use a types.Block to define the whole data structure? I don't see why we need these custom definitions, but I'm also not fully sure what all you are using it for.
DavidVorick
Aug 1, 2017
Member
Is there any particular reason that you can't just use a types.Block to define the whole data structure? I don't see why we need these custom definitions, but I'm also not fully sure what all you are using it for.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
S-anasol
Aug 1, 2017
Contributor
using custom structures with map[string] instead of types with map[] to fill it with any type hashes to make possibility index it with external tools. i.e.
[
[hash] -> [data array]
[hash] -> [data array]
[hash] -> [data array]
]
While default
[
[] -> [data array]
[] -> [data array]
[] -> [data array]
]
Sia internally generate hash every time when it need, like this:
https://github.com/NebulousLabs/Sia/blob/master/types/transactions.go#L217-L248
So default structures doesn't contain hash of anything.
Check this out sia explorer vs my indexer:
https://github.com/S-anasol/SiaConsensusIndexer/blob/master/update.php#L58-L119
https://github.com/NebulousLabs/Sia/blob/master/modules/explorer/update.go#L59
Sia Explorer uses internal functions to calculate hash(ID) for data array,
So making indexer in other language with full copy of Sia hashes calculation is complicated and overheaded.
I hope understandable explanation :)
S-anasol
Aug 1, 2017
•
Contributor
using custom structures with map[string] instead of types with map[] to fill it with any type hashes to make possibility index it with external tools. i.e.
[
[hash] -> [data array]
[hash] -> [data array]
[hash] -> [data array]
]
While default
[
[] -> [data array]
[] -> [data array]
[] -> [data array]
]
Sia internally generate hash every time when it need, like this:
https://github.com/NebulousLabs/Sia/blob/master/types/transactions.go#L217-L248
So default structures doesn't contain hash of anything.
Check this out sia explorer vs my indexer:
https://github.com/S-anasol/SiaConsensusIndexer/blob/master/update.php#L58-L119
https://github.com/NebulousLabs/Sia/blob/master/modules/explorer/update.go#L59
Sia Explorer uses internal functions to calculate hash(ID) for data array,
So making indexer in other language with full copy of Sia hashes calculation is complicated and overheaded.
I hope understandable explanation :)
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
S-anasol
Aug 1, 2017
Contributor
Maybe there is better way to get same result, but i don't know it :)
S-anasol
Aug 1, 2017
Contributor
Maybe there is better way to get same result, but i don't know it :)
| WindowEnd types.BlockHeight `json:"windowend"` | ||
| Payout types.Currency `json:"payout"` | ||
| ValidProofOutputs map[string]types.SiacoinOutput `json:"validproofoutputs"` | ||
| MissedProofOutputs map[string]types.SiacoinOutput `json:"missedproofoutputs"` |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
DavidVorick
Aug 1, 2017
Member
I don't think using a map here is the right move, maps in go are randomly ordered, but valid and missed proofs have a specific order, and the order is meaningful.
DavidVorick
Aug 1, 2017
Member
I don't think using a map here is the right move, maps in go are randomly ordered, but valid and missed proofs have a specific order, and the order is meaningful.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
S-anasol
Aug 1, 2017
Contributor
comment above should answer this too :)
If we dont need this maps at all, it can be removed and used types package.
S-anasol
Aug 1, 2017
Contributor
comment above should answer this too :)
If we dont need this maps at all, it can be removed and used types package.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
DavidVorick
Aug 2, 2017
Member
Ok. My very strong preference is that we just return a normal types.Block. If someone does end up needing the hashes to be computed for them, we can return all the ids (txids, block id, output ids, etc.) in a separate struct that mirrors the block, except it only has ids as fields. But if nobody is using it, we don't need it.
DavidVorick
Aug 2, 2017
Member
Ok. My very strong preference is that we just return a normal types.Block. If someone does end up needing the hashes to be computed for them, we can return all the ids (txids, block id, output ids, etc.) in a separate struct that mirrors the block, except it only has ids as fields. But if nobody is using it, we don't need it.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
DavidVorick
Aug 1, 2017
Member
All changes to the API require two things:
-
Updates to doc/API.md and the corresponding doc/api/module.md, explaining the full route, all the fields and their meanings, and providing basic example usages.
-
A test in the api package demonstrating that the route works. Doesn't need to be super comprehensive but does need to show that the fields returned have non-zero values and that basic error handling (incorrect height, id, etc.) is in place.
I'm not sure what the reason was for making the valid and missed proofs part of a map, but I think we should look at a different way of accomplishing your goal. I think it would be much cleaner if the base types were not changed, and any extra/augmenting information should be in a separate data structure.
|
All changes to the API require two things:
I'm not sure what the reason was for making the valid and missed proofs part of a map, but I think we should look at a different way of accomplishing your goal. I think it would be much cleaner if the base types were not changed, and any extra/augmenting information should be in a separate data structure. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
tbenz9
Nov 10, 2017
Collaborator
@S-anasol are you still interested in working on this PR or should we close it?
|
@S-anasol are you still interested in working on this PR or should we close it? |


S-anasol commentedJun 28, 2017
•
edited
Mini real-time blocks explorer.
Since internal block explorer unusable, we need at least possibility to get 'raw' blocks from siad.
I know that explorer have similar function, but:
Also i believe that blocks api should be in consensus module.