Giter Site home page Giter Site logo

Comments (6)

oancius avatar oancius commented on August 29, 2024 1

With your version when we will receive an incomplete block or undefined we will also delete the data about last correct block... Regarding why we receive bad data...it's an Infura issue i guess, maybe they only know that a new block was mined but they don't have full header of that block and when we ask for that block we get undefined or incomplete data..

from ethereum-lite-explorer.

lookfirst avatar lookfirst commented on August 29, 2024 1

Ah, I get it. Thanks for the explanation. Hmm... then the other code style would be to remove all the nesting so that there is only one assignment... I could go either way really... this is just semantics at this point and I don't mean to be a pain.

setLastBlockFull(state, block) {
  if (!state.lastBlockFull || 
     (block && block.number && state.lastBlockFull.number < block.number)) {
       state.lastBlockFull = block;
  }
},

from ethereum-lite-explorer.

oancius avatar oancius commented on August 29, 2024 1

I will test your final version and if it works (i think it will work) i will use it because it's not so nested :)
Thank you!

from ethereum-lite-explorer.

oancius avatar oancius commented on August 29, 2024 1

Added in #21 :)

from ethereum-lite-explorer.

lookfirst avatar lookfirst commented on August 29, 2024

Could the logic for this method be simplified?

    setLastBlockFull(state, block) {
      if (state.lastBlockFull) {
        if (block && block.number) {
          if (state.lastBlockFull.number < block.number) {
            state.lastBlockFull = block;
          }
        }
      } else {
        state.lastBlockFull = block;
      }
    },

to this...

    setLastBlockFull(state, block) {
        if (block && block.number) {
          if (!state.lastBlockFull || state.lastBlockFull.number < block.number) {
            state.lastBlockFull = block;
          }
        } else {
           state.lastBlockFull = undefined;
        }
    },

The part that I'm not sure is if/why block would be undefined/null. I'd rather see it explicitly set to undefined instead because that creates self documenting code.

from ethereum-lite-explorer.

lookfirst avatar lookfirst commented on August 29, 2024

Oh, I wish there were automated tests. ;-) #4

from ethereum-lite-explorer.

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.