<commit_before>
'''contains main protocol logic like assembly of proof-of-timeline and parsing deck info'''

from pypeerassets import paproto, pautils, RpcNode

def find_all_valid_decks(node, testnet=True, prod_or_test="prod"):
    '''scan the blockchain for PeerAssets decks, returns list of deck objects.'''

    decks = []
    deck_spawns = pautils.find_deck_spawns(node) # find all deck_spawns on PAProd P2TH

    for i in deck_spawns:
        try:
            pautils.validate_deckspawn_p2th(node, i, testnet=testnet, prod_or_test="prod")
            d = pautils.parse_deckspawn_metainfo(pautils.read_tx_opreturn(node, i))
            d["asset_id"] = i
            decks.append(Deck(**d))

        except AssertionError:
            pass

    return decks

class Deck:

    def __init__(self, version, name, number_of_decimals, issue_mode, asset_specific_data, asset_id=None):
        '''initialize deck object, load from dictionary Deck(**dict) or initilize with kwargs Deck(1, "deck", 3, 2)'''

        self.version = version # protocol version
        self.name = name # deck name
        self.issue_mode = issue_mode # deck issue mode
        self.number_of_decimals = number_of_decimals
        self.asset_specific_data = asset_specific_data # optional metadata for the deck
        self.asset_id = asset_id

    @property<commit_msg>pa: add Deck p2th calculation.<commit_after>
'''contains main protocol logic like assembly of proof-of-timeline and parsing deck info'''

from pypeerassets import paproto, pautils, Kutil, RpcNode

def find_all_valid_decks(node, testnet=True, prod_or_test="prod"):
    '''scan the blockchain for PeerAssets decks, returns list of deck objects.'''

    decks = []
    deck_spawns = pautils.find_deck_spawns(node) # find all deck_spawns on PAProd P2TH

    for i in deck_spawns:
        try:
            pautils.validate_deckspawn_p2th(node, i, testnet=testnet, prod_or_test="prod")
            d = pautils.parse_deckspawn_metainfo(pautils.read_tx_opreturn(node, i))
            d["asset_id"] = i
            decks.append(Deck(**d))

        except AssertionError:
            pass

    return decks

class Deck:

    def __init__(self, version, name, number_of_decimals, issue_mode, asset_specific_data, asset_id=None):
        '''initialize deck object, load from dictionary Deck(**dict) or initilize with kwargs Deck(1, "deck", 3, 2)'''

        self.version = version # protocol version
        self.name = name # deck name
        self.issue_mode = issue_mode # deck issue mode
        self.number_of_decimals = number_of_decimals
        self.asset_specific_data = asset_specific_data # optional metadata for the deck
        self.asset_id = asset_id

    @property
    def p2th_addr(self):
        '''P2TH address of this deck'''

        return Kutil(seed=self.asset_id).address

    @property
    def p2th_wif(self):
        '''P2TH privkey in WIF format'''

        return Kutil(seed=self.asset_id).wif

    @property
{'fraction_non_alphanumeric': 0.08995956873315364, 'fraction_numerical': 0.005053908355795148, 'mean_word_length': 3.1994342291371995, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3992709', 'n_tokens_mistral': 974, 'n_tokens_neox': 933, 'n_words': 250}