Exemplo n.º 1
0
 def get(self, block_id=None):
     rows = int(self.get_query_argument('rows', default='-1'))
     offset = int(self.get_argument('offset', default='-1'))
     if rows < 1:
         rows = None
     if offset < 1:
         offset = None
     results = [verification for verification in verification_db.get_all(limit=rows, offset=offset, block_id=block_id)]
     self.write(json.dumps(results))
Exemplo n.º 2
0
 def get(self, block_id=None):
     rows = int(self.get_query_argument('rows', default='-1'))
     offset = int(self.get_argument('offset', default='-1'))
     if rows < 1:
         rows = None
     if offset < 1:
         offset = None
     results = [
         verification for verification in verification_db.get_all(
             limit=rows, offset=offset, block_id=block_id)
     ]
     self.write(json.dumps(results))
Exemplo n.º 3
0
    def execute_ssc(self, min_block_id, vr_limit, txn_limit):
        """ execute subscription smart contract """
        for sc_key in self.ssc.keys():
            (origin_id, txn_type, phase) = sc_key.split(":")
            vrs = verification_db.get_all(limit=vr_limit,
                                          origin_id=origin_id,
                                          phase=phase,
                                          min_block_id=min_block_id)
            #dedupe block ids
            block_ids = {v['block_id'] for v in vrs}
            #group vr's by block id
            block_vrs = defaultdict(list)
            for v in vrs:
                block_vrs[v['block_id']].append(v)

            # fetch all txns for each block
            for block_id in block_ids:
                #todo: filter by p1 signatory
                txns = transaction_db.get_all(transaction_type=txn_type,
                                              block_id=block_id,
                                              limit=txn_limit)
                # execute ssc for each vr in block
                for v in block_vrs[block_id]:
                    self.ssc[sc_key](txns, v)