Skip to content

Commit

Permalink
added the TransactionSchema class to transaction file for simplicity
Browse files Browse the repository at this point in the history
  • Loading branch information
obamwonyi committed Apr 10, 2024
1 parent 7114d15 commit b00a9c9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
3 changes: 1 addition & 2 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import asyncio
from src.transaction import Transaction
from src.schema import TransactionSchema
from src.transaction import Transaction, TransactionSchema
from src.validation import validate_transactions
from src.mine import Mine

Expand Down
11 changes: 0 additions & 11 deletions src/schema.py

This file was deleted.

16 changes: 15 additions & 1 deletion src/transaction.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
from marshmallow import Schema, fields, post_load

class TransactionSchema(Schema):
version = fields.Int(required=True)
locktime = fields.Int(required=True)
vin = fields.List(fields.Dict(), required=True)
vout = fields.List(fields.Dict(), required=True)

@post_load
def make_transaction(self, data, **kwargs):
return Transaction(**data)

class Transaction:
"""
This class holds method for managing transactions
"""
pass
def __init__(self, version, locktime, vin, vout) -> None:
self.version = version
self.locktime = version
self.vin = vin
self.vout = vout

0 comments on commit b00a9c9

Please sign in to comment.