Esempio n. 1
0
    def __init__(self):
        # Create 3 thread-pools each with 1 thread
        self.network_service = bitcoin.async_service(1)
        self.disk_service = bitcoin.async_service(1)
        self.mempool_service = bitcoin.async_service(1)

        self.hosts = bitcoin.hosts(self.network_service)
        self.handshake = bitcoin.handshake(self.network_service)
        self.network = bitcoin.network(self.network_service)
        self.protocol = bitcoin.protocol(self.network_service, self.hosts,
                                         self.handshake, self.network)

        db_prefix = "/home/genjix/libbitcoin/database"
        self.blockchain = bitcoin.bdb_blockchain(self.disk_service, db_prefix,
                                                 self.blockchain_started)
        self.poller = bitcoin.poller(self.mempool_service, self.blockchain)
        self.transaction_pool = \
            bitcoin.transaction_pool(self.mempool_service, self.blockchain)

        self.protocol.subscribe_channel(self.monitor_tx)
        self.session = \
            bitcoin.session(self.network_service, self.hosts, self.handshake,
                            self.network, self.protocol, self.blockchain,
                            self.poller, self.transaction_pool)
        self.session.start(self.handle_start)

        self.memory_buffer = \
            membuf.memory_buffer(self.mempool_service.internal_ptr,
                                 self.blockchain.internal_ptr,
                                 self.transaction_pool.internal_ptr)
Esempio n. 2
0
    def __init__(self):
        # Create 3 thread-pools each with 1 thread
        self.network_service = bitcoin.async_service(1)
        self.disk_service = bitcoin.async_service(1)
        self.mempool_service = bitcoin.async_service(1)

        self.hosts = bitcoin.hosts(self.network_service)
        self.handshake = bitcoin.handshake(self.network_service)
        self.network = bitcoin.network(self.network_service)
        self.protocol = bitcoin.protocol(self.network_service, self.hosts,
                                         self.handshake, self.network)

        db_prefix = "/home/genjix/libbitcoin/database"
        self.blockchain = bitcoin.bdb_blockchain(self.disk_service, db_prefix,
                                                 self.blockchain_started)
        self.poller = bitcoin.poller(self.mempool_service, self.blockchain)
        self.transaction_pool = \
            bitcoin.transaction_pool(self.mempool_service, self.blockchain)

        self.protocol.subscribe_channel(self.monitor_tx)
        self.session = \
            bitcoin.session(self.network_service, self.hosts, self.handshake,
                            self.network, self.protocol, self.blockchain,
                            self.poller, self.transaction_pool)
        self.session.start(self.handle_start)

        self.memory_buffer = \
            membuf.memory_buffer(self.mempool_service.internal_ptr,
                                 self.blockchain.internal_ptr,
                                 self.transaction_pool.internal_ptr)
Esempio n. 3
0
 def __init__(self):
     self._net_pool = bitcoin.threadpool(1)
     self._disk_pool = bitcoin.threadpool(1)
     self._mem_pool = bitcoin.threadpool(1)
     self._hosts = bitcoin.hosts(self._net_pool)
     self._handshake = bitcoin.handshake(self._net_pool)
     self._network = bitcoin.network(self._net_pool)
     self._protocol = bitcoin.protocol(self._net_pool, self._hosts,
                                       self._handshake, self._network)
     self._chain = bitcoin.leveldb_blockchain(self._disk_pool)
     self._poller = bitcoin.poller(self._mem_pool, self._chain)
     self._txpool = bitcoin.transaction_pool(self._mem_pool, self._chain)
     pars = bitcoin.create_session_params(self._handshake, self._protocol,
                                          self._chain, self._poller,
                                          self._txpool)
     self._session = bitcoin.session(self._net_pool, pars)
     self._tx_subscribe = Subscriber()
Esempio n. 4
0
 def __init__(self):
     self._net_pool = threadpool(1)
     self._disk_pool = threadpool(1)
     self._mem_pool = threadpool(1)
     self._hosts = hosts(self._net_pool)
     self._handshake = handshake(self._net_pool)
     self._network = network(self._net_pool)
     self._protocol = protocol(self._net_pool,
                               self._hosts,
                               self._handshake,
                               self._network)
     self._chain = leveldb_blockchain(self._disk_pool)
     self._poller = poller(self._mem_pool, self._chain)
     self._txpool = transaction_pool(self._mem_pool, self._chain)
     pars = create_session_params(self._handshake,
                                  self._protocol,
                                  self._chain,
                                  self._poller,
                                  self._txpool)
     self._session = session(self._net_pool, pars)
     self.report("[fullnode] ok")
Esempio n. 5
0
    def __init__(self):
        self._net_pool = bitcoin.threadpool(1)
        self._disk_pool = bitcoin.threadpool(1)
        self._mem_pool = bitcoin.threadpool(1)
        self._hosts = bitcoin.hosts(self._net_pool)
        self._handshake = bitcoin.handshake(self._net_pool)
        self._network = bitcoin.network(self._net_pool)
        self._protocol = bitcoin.protocol(self._net_pool,
                                          self._hosts,
                                          self._handshake,
                                          self._network)
        self._chain = bitcoin.leveldb_blockchain(self._disk_pool)
        self._poller = bitcoin.poller(self._mem_pool, self._chain)
        self._txpool = bitcoin.transaction_pool(self._mem_pool, self._chain)
        pars = bitcoin.create_session_params(self._handshake,
				                             self._protocol,
				                             self._chain,
				                             self._poller,
				                             self._txpool)
        self._session = bitcoin.session(self._net_pool, pars)
        self._tx_subscribe = Subscriber()
import bitcoin

def start_polling(ec, node, poll):
    if ec:
        print ec
        return
    poll.query(node)

if __name__ == "__main__":
    s1 = bitcoin.async_service(1)
    s2 = bitcoin.async_service(1)
    chain = bitcoin.bdb_blockchain(s1, "database")
    poll = bitcoin.poller(chain)
    net = bitcoin.network(s2)
    hs = bitcoin.handshake(s2)
    hs.connect(net, "localhost", 8333,
        bitcoin.bind(start_polling, bitcoin._1, bitcoin._2, poll))
    raw_input()