Skip to content

Commit

Permalink
Merge pull request #179 from abitmore/fix-tapos
Browse files Browse the repository at this point in the history
Expire TaPoS cache after one day, fix #144
  • Loading branch information
xeroc authored Jul 1, 2021
2 parents 1dad1d8 + 689e64e commit 20d69fd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions graphenecommon/transactionbuilder.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
import struct
import logging
from datetime import datetime, timedelta
from binascii import unhexlify
from .exceptions import (
InsufficientAuthorityError,
Expand All @@ -17,7 +18,7 @@

class ProposalBuilder(AbstractBlockchainInstanceProvider):
""" Proposal Builder allows us to construct an independent Proposal
that may later be added to an instance ot TransactionBuilder
that may later be added to an instance of TransactionBuilder
:param str proposer: Account name of the proposing user
:param int proposal_expiration: Number seconds until the proposal is
Expand Down Expand Up @@ -400,8 +401,10 @@ def constructTx(self):
or self.blockchain.expiration
or 30 # defaults to 30 seconds
)
if not self.get("ref_block_num"):
now = datetime.now()
if not self.get("ref_block_num") or now > self.get("ref_block_time") + datetime.timedelta(days=1) :
ref_block_num, ref_block_prefix = self.get_block_params()
ref_block_time = now
else:
ref_block_num = self["ref_block_num"]
ref_block_prefix = self["ref_block_prefix"]
Expand Down

0 comments on commit 20d69fd

Please sign in to comment.