Closed fkbenjamin closed 4 years ago
Hi @fkbenjamin. go-tezos
is still a currently evolving project, but the function you're looking for is gt.Cycle
, which will give you the blockhash needed. Because it's evolving there may be breaking changes before the official v2.0.0
tag is used. Currently I am tagging things as alpha. I would recommend using V2 over V1, because even it's alpha state it is much safer and tested.
/*
Cycle represents the cycle RPC.
RPC:
../blocks/<block_id>/context/raw/json/cycle/<cycle_number> (GET)
*/
type Cycle struct {
RandomSeed string `json:"random_seed"`
RollSnapshot int `json:"roll_snapshot"`
BlockHash string `json:"-"`
}
Here's the documentation you need: https://godoc.org/github.com/goat-systems/go-tezos
@fkbenjamin also I think we may be working on similar things, here is my payout script: https://github.com/goat-systems/tzpay
Specifically the delegation calculations happen here: https://github.com/goat-systems/tzpay/blob/master/internal/payout/payouts.go
Hey @DefinitelyNotAGoat ,
I already saw your tzpay script. This issue was not related to our payout software (working great for over a year now).
I rather wanted to use this to track earnings of bakers on a per-block basis (for auditing & reporting). I just realized that I probably can just copy that part over from our payout tool. I'll have a look at it again once I find the time and maybe submit a PR if I'm missing some functionality.
@fkbenjamin let me know if you need any help! Be happy to take a look at it with you!
With the update of network parameters,
V1
of go-tezos is not working anymore. However, as far as I could see, there is no documentation forV2
(at least I can't find one) and I can't find a way to query Snapshots inV2
:type *gotezos.GoTezos has no field or method SnapShot
Is there a way to get the assiociatedBlock of a cycle in
V2
? I used to do it like this and am looking for a working alternative inV2
.If this is not implemented in
V2
right now, could we updateV1
to support the new network parameters for now? Or maybe there is a better way to query this: I'm looking for a way to determine the percentage of total stake that is coming from the baker itself. Currently, I query the Snapshot, get the block_height of that cycle and query the balances.