Coder Social home page Coder Social logo

Comments (3)

manuelmauro avatar manuelmauro commented on June 15, 2024 1

Hi @epequeno ! Yes, it's quite tricky to find documentation about this one. The current struct is defined starting from a test call towards the API, which makes it a very poor solution. We don't know which fields are optional and which are not for instance.

Your reference seems to be the best source I am able to find. Another source comes from an automatic implementation of the client based on the Open API Schema that suggests the following implementation for the API response (completely avoiding the problem):

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct InlineResponse2001 {
    /// Block header data.
    #[serde(rename = "block")]
    pub block: serde_json::Value,
    /// Optional certificate object. This is only included when the format is set to message pack.
    #[serde(rename = "cert", skip_serializing_if = "Option::is_none")]
    pub cert: Option<serde_json::Value>,
}

If we are not able to find solid docs this solution might be the less error-prone.

from algonaut.

epequeno avatar epequeno commented on June 15, 2024

I'd like to pick this one up, I think I'll need a bit more info to start on this though.

This is the BlockHeader in algod we should be looking at right?
https://github.com/algorand/go-algorand/blob/91b8ca1ed7677f41815c06d7808a17077941c73b/data/bookkeeping/block.go#L38

Which I believe correlates to this struct in the algod messages module:

/// BlockHeader
#[derive(Debug, Serialize, Deserialize)]
pub struct BlockHeader {
pub earn: Option<u64>,
pub fees: String,
pub frac: u64,
pub gen: String,
pub gh: String,
pub prev: String,
pub proto: String,
pub rate: u64,
pub rnd: u64,
pub rwcalr: u64,
pub rwd: String,
pub seed: String,
pub ts: u64,
pub txn: String,
}

I've tried to line these fields up side by side but it reveals that I'm not sure exactly how to map them to each other:

earn: Option<u64>,
fees: String,
frac: u64,
gen: String,     GenesisID string
gh: String,      GenesisHash crypto.Digest
prev: String,
proto: String,
rate: u64,
rnd: u64,        Round basics.Round
rwcalr: u64,
rwd: String,     RewardsState
seed: String,    Seed committee.Seed
ts: u64,         TimeStamp int64
txn: String,     TxnRoot crypto.Digest
                 Branch BlockHash
                 UpgradeState
                 UpgradeVote
                 TxnCounter uint64
                 CompactCert map[protocol.CompactCertType]CompactCertState

I'd like to check in and confirm if I'm on the right track and to ask if you could provide any further guidance on how to proceed.

from algonaut.

ivanschuetz avatar ivanschuetz commented on June 15, 2024

Closing this, as it seems not urgent and it would be solved as part of #164 and #165

from algonaut.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.