<commit_before>#!/usr/bin/python

import json
import sys
import httplib
import decimal
import config
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException

def decimal_default(obj):
    if isinstance(obj, decimal.Decimal):
        return float(obj)
    raise TypeError

conf = config.read_default_config();

processed_file = '/tmp/processed_txs'

try:
  f = open(processed_file,'r')
  data = f.read() # python will convert \n to os.linesep
  f.close() # you can omit in most cases as the destructor will call it
except IOError:
  data = []

# print data
# rpc_user and rpc_password are set in the bitcoin.conf file
rpc_connection = AuthServiceProxy("http://%s:%s@127.0.0.1:8332"%( conf['rpcuser'] , conf['rpcpassword'] ) )

mempool = rpc_connection.getrawmempool()
n = 10 # 100 rpc function call every request
ewtxs = []
for tx in mempool:
  if tx not in data:
    print tx
    txs_data = rpc_connection.getrawtransaction( tx )
    for idx, tx_data in enumerate(txs_data):
      if "455720" in tx_data:
        ewtxs.append( chunk[idx] )

print "-------------"
print "mempool txs " + str(len(mempool))
print ewtxs;    

f = open(processed_file,'w')
f.write( json.dumps(mempool) ) # python will convert \n to os.linesep
f.close() # you can omit in most cases as the destructor will call it

#jsonresult = json.dumps(result, default=decimal_default)
#print(jsonresult)

#conn = httplib.HTTPConnection('eternitywall.it', 80)
#conn.connect()
#conn.request('POST', "/v1/hooks/ewtx?hash=%s" % (block_hash) , jsonresult)
#resp = conn.getresponse()
#conn.close()
#print resp.status, resp.reason


 <commit_msg>calling ew<commit_after>#!/usr/bin/python

import json
import sys
import httplib
import decimal
import config
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException

def decimal_default(obj):
    if isinstance(obj, decimal.Decimal):
        return float(obj)
    raise TypeError

conf = config.read_default_config();

processed_file = '/tmp/processed_txs'

try:
  f = open(processed_file,'r')
  data = f.read() # python will convert \n to os.linesep
  f.close() # you can omit in most cases as the destructor will call it
except IOError:
  data = []

# print data
# rpc_user and rpc_password are set in the bitcoin.conf file
rpc_connection = AuthServiceProxy("http://%s:%s@127.0.0.1:8332"%( conf['rpcuser'] , conf['rpcpassword'] ) )

mempool = rpc_connection.getrawmempool()
n = 10 # 100 rpc function call every request
ewtxs = []
for tx in mempool:
  if tx not in data:
    print tx
    txs_data = rpc_connection.getrawtransaction( tx )
    for idx, tx_data in enumerate(txs_data):
      if "455720" in tx_data:
        decoded = rpc_tion.decoderawtransaction(tx_data)
        ewtxs.append(decoded)

print "-------------"
print "mempool txs " + str(len(mempool))
print ewtxs;    

f = open(processed_file,'w')
f.write( json.dumps(mempool) ) # python will convert \n to os.linesep
f.close() # you can omit in most cases as the destructor will call it

if len(ewtxs)>0 :
  jsonresult = json.dumps(result, default=decimal_default)
  conn = httplib.HTTPConnection('eternitywall.it', 80)
  conn.connect()
  conn.request('POST', "/v1/hooks/ewunconfirmedtx" , jsonresult)
  resp = conn.getresponse()
  conn.close()
  print resp.status, resp.reason


 
{'fraction_non_alphanumeric': 0.12339645693341478, 'fraction_numerical': 0.014966401954795358, 'mean_word_length': 4.077519379844961, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '1846525', 'n_tokens_mistral': 1160, 'n_tokens_neox': 1103, 'n_words': 312}