File tree Expand file tree Collapse file tree 3 files changed +22
-12
lines changed
Expand file tree Collapse file tree 3 files changed +22
-12
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "type" : " minor" ,
3+ "description" : " Use the last irreversible block for tapos ref params"
4+ }
Original file line number Diff line number Diff line change 1616timeformat = "%Y-%m-%dT%H:%M:%S%Z"
1717
1818
19- def getBlockParams (ws ):
19+ def getBlockParams (ws , use_head_block = False ):
2020 """ Auxiliary method to obtain ``ref_block_num`` and
2121 ``ref_block_prefix``. Requires a websocket connection to a
2222 witness node!
2323 """
24- dynBCParams = ws .get_dynamic_global_properties ()
25- ref_block_num = dynBCParams ["head_block_number" ] & 0xFFFF
26- ref_block_prefix = struct .unpack_from (
27- "<I" , unhexlify (dynBCParams ["head_block_id" ]), 4
28- )[0 ]
29- return ref_block_num , ref_block_prefix
24+ raise DeprecationWarning (
25+ "This method shouldn't be called anymore. It is part of "
26+ "transactionbuilder now"
27+ )
3028
3129
3230def formatTimeFromNow (secs = 0 ):
Original file line number Diff line number Diff line change @@ -405,17 +405,25 @@ def constructTx(self):
405405 dict .update (self , self .tx .json ())
406406 self ._unset_require_reconstruction ()
407407
408- def get_block_params (self ):
408+ def get_block_params (self , use_head_block = False ):
409409 """ Auxiliary method to obtain ``ref_block_num`` and
410410 ``ref_block_prefix``. Requires a websocket connection to a
411411 witness node!
412412 """
413413 ws = self .blockchain .rpc
414414 dynBCParams = ws .get_dynamic_global_properties ()
415- ref_block_num = dynBCParams ["head_block_number" ] & 0xFFFF
416- ref_block_prefix = struct .unpack_from (
417- "<I" , unhexlify (dynBCParams ["head_block_id" ]), 4
418- )[0 ]
415+ if use_head_block :
416+ ref_block_num = dynBCParams ["head_block_number" ] & 0xFFFF
417+ ref_block_prefix = struct .unpack_from (
418+ "<I" , unhexlify (dynBCParams ["head_block_id" ]), 4
419+ )[0 ]
420+ else :
421+ # need to get subsequent block because block head doesn't return 'id' - stupid
422+ block = ws .get_block_header (int (dynBCParams ["last_irreversible_block_num" ])+ 1 )
423+ ref_block_num = dynBCParams ["last_irreversible_block_num" ] & 0xFFFF
424+ ref_block_prefix = struct .unpack_from (
425+ "<I" , unhexlify (block ["previous" ]), 4
426+ )[0 ]
419427 return ref_block_num , ref_block_prefix
420428
421429 def sign (self ):
You can’t perform that action at this time.
0 commit comments