Skip to content

Commit

Permalink
Merge pull request #834 from CounterpartyXCP/develop
Browse files Browse the repository at this point in the history
v9.54.0
  • Loading branch information
Ouziel Slama committed Mar 5, 2016
2 parents 2d602c6 + f12c68e commit 7d97da4
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ profile.txt
*.pyc

# files generated by py.test
test/fixtures/scenarios/*.new.*
/counterpartylib/test/fixtures/scenarios/*.new.*
.coverage

# Compiled python modules.
Expand Down
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
## Library Versions ##
* v9.54.0 (2016-03-05)
* Execute post install tasks when called via `pip`
* Max fee fraction of 1
* Don't handle bet matches for invalid broadcast.
* v9.53.0 (2016-01-18)
* Remove `messages` table from being covered by "undolog" functionality added in `v9.52.0`.
* Add `min_message_index` to `get_blocks` API call.
Expand Down
22 changes: 11 additions & 11 deletions counterpartylib/lib/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def parse_block(db, block_index, block_time,

assert block_index == util.CURRENT_BLOCK_INDEX

# Remove undolog records for any block older than we should be tracking
# Remove undolog records for any block older than we should be tracking
undolog_oldest_block_index = block_index - config.UNDOLOG_MAX_PAST_BLOCKS
first_undo_index = list(undolog_cursor.execute('''SELECT first_undo_index FROM undolog_block WHERE block_index == ?''',
(undolog_oldest_block_index,)))
Expand Down Expand Up @@ -715,15 +715,15 @@ def reinitialise(db, block_index=None):
if block_index:
cursor.execute('''DELETE FROM transactions WHERE block_index > ?''', (block_index,))
cursor.execute('''DELETE FROM blocks WHERE block_index > ?''', (block_index,))

cursor.close()

def reparse(db, block_index=None, quiet=False):
"""Reparse all transactions (atomically). If block_index is set, rollback
to the end of that block.
"""
def reparse_from_undolog(db, block_index, quiet):
"""speedy reparse method that utilizes the undolog.
"""speedy reparse method that utilizes the undolog.
if fails, fallback to the full reparse method"""
if not block_index:
return False # Can't reparse from undolog
Expand All @@ -746,7 +746,7 @@ def get_block_index_for_undo_index(undo_indexes, undo_index):
undo_indexes = collections.OrderedDict()
for result in results:
undo_indexes[result[0]] = result[1]

undo_start_block_index = block_index + 1

if undo_start_block_index not in undo_indexes:
Expand Down Expand Up @@ -776,7 +776,7 @@ def get_block_index_for_undo_index(undo_indexes, undo_index):

undolog_cursor.close()
return True

if block_index:
logger.info('Rolling back transactions to block {}.'.format(block_index))
else:
Expand All @@ -788,7 +788,7 @@ def get_block_index_for_undo_index(undo_indexes, undo_index):
reparsed = reparse_from_undolog(db, block_index, quiet)

cursor = db.cursor()

if not reparsed:
if block_index:
logger.info("Could not roll back from undolog. Performing full reparse instead...")
Expand Down Expand Up @@ -952,7 +952,7 @@ def kickstart(db, bitcoind_dir):
tx_chunks = [transactions[i:i+90] for i in range(0, len(transactions), 90)]
for tx_chunk in tx_chunks:
sql = '''INSERT INTO transactions
(tx_index, tx_hash, block_index, block_hash, block_time, source, destination, btc_amount, fee, data)
(tx_index, tx_hash, block_index, block_hash, block_time, source, destination, btc_amount, fee, data)
VALUES '''
bindings = ()
bindings_place = []
Expand Down Expand Up @@ -1047,7 +1047,7 @@ def follow(db):
not_supported_sorted = collections.deque()
# ^ Entries in form of (block_index, tx_hash), oldest first. Allows for easy removal of past, unncessary entries
cursor = db.cursor()

# a reorg can happen without the block count increasing, or even for that
# matter, with the block count decreasing. This should only delay
# processing of the new blocks a bit.
Expand Down Expand Up @@ -1143,7 +1143,7 @@ def follow(db):
for tx_hash in txhash_list:
tx_hex = raw_transactions[tx_hash]
tx_index = list_tx(db, block_hash, block_index, block_time, tx_hash, tx_index, tx_hex)

# Parse the transactions in the block.
new_ledger_hash, new_txlist_hash, new_messages_hash, found_messages_hash = parse_block(db, block_index, block_time)

Expand All @@ -1161,7 +1161,7 @@ def follow(db):
str(block_index), "{:.2f}".format(time.time() - start_time, 3),
new_ledger_hash[-5:], new_txlist_hash[-5:], new_messages_hash[-5:],
(' [overwrote %s]' % found_messages_hash) if found_messages_hash and found_messages_hash != new_messages_hash else ''))

# Increment block index.
block_count = backend.getblockcount()
block_index += 1
Expand Down Expand Up @@ -1266,7 +1266,7 @@ def follow(db):
tx_hash, new_message = message
new_message['tx_hash'] = tx_hash
cursor.execute('''INSERT INTO mempool VALUES(:tx_hash, :command, :category, :bindings, :timestamp)''', new_message)

refresh_start_time = time.time()
# let the backend refresh it's mempool stored data
# Sometimes the transactions can’t be found: `{'code': -5, 'message': 'No information available about transaction'}`
Expand Down
2 changes: 1 addition & 1 deletion counterpartylib/lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Versions
VERSION_MAJOR = 9
VERSION_MINOR = 53
VERSION_MINOR = 54
VERSION_REVISION = 0
VERSION_STRING = str(VERSION_MAJOR) + '.' + str(VERSION_MINOR) + '.' + str(VERSION_REVISION)

Expand Down
12 changes: 10 additions & 2 deletions counterpartylib/lib/messages/broadcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ def initialise(db):
def validate (db, source, timestamp, value, fee_fraction_int, text, block_index):
problems = []

if fee_fraction_int > 4294967295:
problems.append('fee fraction greater than 42.94967295')
if util.enabled('max_fee_fraction'):
if fee_fraction_int >= config.UNIT:
problems.append('fee fraction greater than or equal to 1')
else:
if fee_fraction_int > 4294967295:
problems.append('fee fraction greater than 42.94967295')

if timestamp < 0: problems.append('negative timestamp')

Expand Down Expand Up @@ -188,6 +192,10 @@ def parse (db, tx, message):
ORDER BY tx1_index ASC, tx0_index ASC''',
('pending', tx['source']))
for bet_match in cursor.fetchall():
if util.enabled('max_fee_fraction'):
if status != 'valid':
break

broadcast_bet_match_cursor = db.cursor()
bet_match_id = util.make_id(bet_match['tx0_hash'], bet_match['tx1_hash'])
bet_match_status = None
Expand Down
6 changes: 6 additions & 0 deletions counterpartylib/protocol_changes.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,11 @@
"minimum_version_minor": 51,
"minimum_version_revision": 0,
"block_index": 352000
},
"max_fee_fraction": {
"minimum_version_major": 9,
"minimum_version_minor": 54,
"minimum_version_revision": 0,
"block_index": 401278
}
}
2 changes: 1 addition & 1 deletion counterpartylib/test/fixtures/vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@
'out': (['locked feed'])
}, {
'in': (ADDR[0], 1588000000, 1, 4294967296, 'Unit Test', DP['default_block']),
'out': (['fee fraction greater than 42.94967295'])
'out': (['fee fraction greater than or equal to 1'])
}, {
'in': (ADDR[0], -1388000000, 1, DP['fee_multiplier'], 'Unit Test', DP['default_block']),
'out': (['negative timestamp', 'feed timestamps not monotonically increasing'])
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ def _called_from_setup(run_frame):
def run(self):
# Explicit request for old-style install? Just do it
if self.old_and_unmanageable or self.single_version_externally_managed:
return _install.run(self)
_install.run(self)
self.execute(post_install, (self, False), msg="Running post install tasks")
return

if not self._called_from_setup(inspect.currentframe()):
# Run in backward-compatibility mode to support bdist_* commands.
Expand Down

0 comments on commit 7d97da4

Please sign in to comment.