Skip to content

Instantly share code, notes, and snippets.

@hashware
Created June 24, 2018 08:50
Show Gist options
  • Save hashware/e7348dafd575fff7fb021447357f5f90 to your computer and use it in GitHub Desktop.
Save hashware/e7348dafd575fff7fb021447357f5f90 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# coding:utf-8

from pymongo import MongoClient

conn = MongoClient('127.0.0.1', 27017)
db = conn.eosdb
eosset = db.eosset


#q = eosset.find({"block_num": 191})
#for x in q:
#    print(x)
    print(x['block_num'])

q = eosset.find({"transactions":
                     {"$elemMatch":
                         {"trx.transaction.actions":
                              {"$elemMatch":
                                   {"name":"newaccount"}
                              }
                         }
                     }
                })

print("len(q)", q.count())
cnt = 0
for x in q:
    transactions = x['transactions']
    for t in transactions:
        try:
            actions = t['trx']['transaction']['actions']
            for a in actions:
                name = a['name']
                if name == 'newaccount':
                    cnt += 1
        except Exception as e:
            pass

print(cnt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment