Giter VIP home page Giter VIP logo

Comments (1)

clayrab avatar clayrab commented on August 11, 2024

I noticed some things about utxoset that I didn't like and it turned into a fairly large refactor.

I'm sorry that I've mixed a few issues into one here, but they somehow all seemed related when I was doing all this yesterday.

There are 3 issues I've tried to tackle here:

  1. The API in utxoset seemed wrong to me. This PR reduces the interface to just insert_transaction, reward_transaction, and slip_block_id. I also wasn't sure if the implementation of those was correct, so I've attempted to correct it.

  2. Slip was not designed well. An Output consists of an amount, and address, and a type. An Input needs a reference to an Output, which is essentially and ID, which is a triple of block_id, tx_id, and slip_id in saito-lite. The previous Slip struct made it impossilbe to pass around references to slips without the slips themselves. Additionally, the id fields has to be zeroed or None-ed in cases where they weren't needed. This made the utxoset unnecessarily heavy and also made the Slip struct unwieldy. For example code in the add_block function was already setting these fields to 0 in some conditional. The new Structs are both easier to use and also add type-safety because there are some cases where you need a Slip/Output(address, amount, type) and other cases where you need a reference to that Slip. I've additionally named the base slip type to SaitoSlip, just to make it easier to grep for.

  3. The structure for Transaction suffered from similar problems. The signature was part of the Body, which made it necessary to manage even in cases where a signature might not be needed. This is also confusing because the Body is the part that should be both serialized and signed, so the signature really should not be part of it. The new structure removes the signature from the body and also adds a new type SignedTransasction, which allows the type system to help enforce and communicate when and API expects a transaction to be signed. I've also renamed Transaction to RuntimeTransaction, which I think reflects it's usage(it will be needed by utxo set to map slips to blocks) and also makes it easier to grep for in the code.

I want to submit this PR now because I believe it's better to get it merged before the add_block_to_blockchain work is done. I still need to add comments/documentation to some things and one of the tests in utxoset needs to be written but I want to get this PR in front of the team before I go home tonight.

from saito-rust.

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.