Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fee to Block #59

Merged
merged 10 commits into from
Feb 13, 2021
Merged

Conversation

danpadev
Copy link
Contributor

@danpadev danpadev commented Feb 9, 2021

Issue #54

@danpadev danpadev changed the title Issue54 Add fee to Block Feb 9, 2021

if len(fee_list) != len(fee_set):
raise serializers.ValidationError('Tx fees must be unique')

Copy link
Collaborator

@buckyroberts buckyroberts Feb 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic won't quite work since there could be multiple non-fee Txs. In this case the fee_list would have multiple None items but would still be valid.

txs = [
    {
        "amount": 12.5,
        "recipient": "484b3176c63d5f37d808404af1a12c4b9649cd6f6769f35bdf5a816133623fbc"
    },
    {
        "amount": 18.5,
        "recipient": "684b3176c63d5f37d808404af1a12c4b9649cd6f6769f35bdf5a816133623fbc"
    },
    {
        "amount": 1,
        "fee": 'BANK',
        "recipient": "5e12967707909e62b2bb2036c209085a784fabbc3deccefee70052b6181c8ed8"
    },
    {
        "amount": 4,
        "fee": 'PV',
        "recipient": "ad1f8845c6a1abb6011a2a434a079a087c460657aad54329a84b406dce8bf314"
    }
]

fee_list = [tx.get('fee', None) for tx in txs]
fee_set = set(fee_list)
error = bool(len(fee_list) != len(fee_set))

print(error)

@buckyroberts buckyroberts merged commit 241c64d into thenewboston-blockchain:development Feb 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants