JacobCairncross / Kebab

0 stars 0 forks source link

Check for double spend #1

Open JacobCairncross opened 5 months ago

JacobCairncross commented 5 months ago

Need to check if a transaction output has been used before allowing it to be used as a transaction input.

Can do this by maintaining an index of all unspent transactions to make checking speedier.

Would be best to implement entity framework properly before doing this so we can store stuff better than just in the object (make sure to have an option to clear the db on start up though for easier testing)

JacobCairncross commented 5 months ago

Been deciding how to minimise the lifetime of the db but having the lifetime be for the whole request should be fine https://learn.microsoft.com/en-us/ef/ef6/fundamentals/working-with-dbcontext#lifetime so you can just inject it into the constructor of where its needed

JacobCairncross commented 5 months ago

need to rework the dependancy injection to ensure I dont put the db context into a singleton. It may be best to make everything scoped and then build the chain up from the DB each time its needed. This seems like it'll be slow but it might be fine. Also think how this works when we switch to doing a block of multiple requests and not just a block per request. Better yet, rework the blockchain class so it doesnt build up, it just accesses the db for you.

JacobCairncross commented 4 months ago

Maybe actually reading a bit of documentation might help https://learn.microsoft.com/en-us/ef/core/modeling/relationships/one-to-many

JacobCairncross commented 4 months ago

DB is set up for the genesis transaction. Need to ensure it works for transactions afterwards, then focus on double spend

JacobCairncross commented 3 months ago

Got the db in a docker container now, just need to alter connection string to allow it to connect. Living the high life. DO NOT forget to switch to an actual secrets system once this works

JacobCairncross commented 3 months ago

DB is being made as pg_database_owner but I'm checking it as user. Theres a chance it will just work? but find a way to authorise schema to the user I'm logging in as so I can check the tables arebeing made correctly