Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: etotheipi on October 06, 2011, 11:04:56 PM



Title: PBE BlockExplorer: a PyBtcEngine Demo
Post by: etotheipi on October 06, 2011, 11:04:56 PM
I released the source code for PyBtcEngine the other day in this thread (https://bitcointalk.org/index.php?topic=46485.0).  It is a highly-efficient, standalone, computational engine for Bitcoin development in Python, using C++/SWIG in the background.  Since then, I have created a powerful block-explorer to demonstrate what the library can do (compare to the same info on blockexplorer.com (http://blockexplorer.com/block/000000000000b731f2eef9e8c63173adfb07e41bd53eb0ef0a6b720d6cb6dea4)):

http://dl.dropbox.com/u/1139081/BitcoinImg/PyBtcEngineExplorer.png
Full size img available here (http://dl.dropbox.com/u/1139081/BitcoinImg/PyBtcEngineExplorer_FullSize.png)

This GUI is by no means complete, but it is usable and demonstrates the completeness of functionality available in Python with PBE.  You can search by block number, or any hash in any endianness - and there are no temporary/helper files to do this -- everything is loaded from blk0001.dat in less than 20 seconds!  

Recent Updates:
  • Tested on Ubuntu 11.04 64-bit, and 10.04 32-bit with both Python 2.6 and 2.7.  Some strange display issues with it in 10.04 in VirtualBox, let me know if you it works for you.
  • GUI auto-updates when your client receives new block data.
  • Still haven't figured out running it on Windows, but I've done most of the hard work -- included MSVS 2010 project with the swig command as a pre-build event and compiles the wrapper.  Will be adding MSVS 2005 project soon.


There's a billion things I'm working on adding, such as address views/searching (implemented in the library, but not part of the GUI, yet), multiple search results, and more detailed information on double-click. Suggestions are welcome, but I have plenty of low-hanging fruit to grab.

Compiling and using this library in Ubuntu is very easy if you have  Python 2.6 or 2.7:
  • sudo apt-get install build-essential libcrypto++-dev swig libqtcore4 libqt4-dev python-qt4 python-dev
  • git clone git://github.com/etotheipi/PyBtcEngine.git
  • cd PyBtcEngine/cppForSwig
  • make swig
  • cd ../pyqt
  • python blockexplore.pyw

If the library didn't autodetect your blockfile, you can supply it as the first/only argument to the blockexplore script, usually ~/.bitcoin/blk0001.dat.  Keep in mind, this is still the full-RAM implementation, so it's going to store everything in RAM while you use it:  about 1GB.  I will be making it more lightweight in the future, but at the moment I'm focusing on implementing new features, and improving access to the existing ones.



PLEASE HELP me figure out how to get this running in Windows.  I have everything compiling and automated in MSVS.  However, I cannot seem to import the module/dll or PyQt4, so the GUI won't load.  I hope someone with more experience can help me figure this out.

To learn more about the library, read "Using_PyBtcEngine.README" in the root project directory, and see my intro thread on PyBtcEngine (https://bitcointalk.org/index.php?topic=46485.0) for more information.


Title: Re: PBE BlockExplorer: a PyBtcEngine Demo
Post by: Mobius on October 07, 2011, 02:56:10 PM
Slight problem:

g++  -I/usr/include/python2.7  -c -march=native -O2 -pipe  -Icryptopp -fPIC -DUSE_CRYPTOPP -D__STDC_LIMIT_MACROS -Lcryptopp -lcryptopp CppBlockUtils_wrap.cxx
CppBlockUtils_wrap.cxx:149: fatal error: Python.h: No such file or directory
compilation terminated.
make: *** [CppBlockUtils_wrap.o] Error 1


Title: Re: PBE BlockExplorer: a PyBtcEngine Demo
Post by: 2112 on October 07, 2011, 03:45:37 PM
CppBlockUtils_wrap.cxx:149: fatal error: Python.h: No such file or directory
Just install the appropriate python-dev for your system.

Edit:

To fix the next little buglet change -lcryptopp to $(LIBRARY_OPTS) in the g++ invocation under swig.


Title: Re: PBE BlockExplorer: a PyBtcEngine Demo
Post by: etotheipi on October 07, 2011, 03:48:44 PM
Fixed the instructions above to include python-dev.  It's tough to tell what is needed because I already have a lot of these packages installed on my system.

EDIT: I tried to get this working in Python 2.6, but found it's not a trivial change.  For now this will only be compatible with Python 2.7


Title: Re: PBE BlockExplorer: a PyBtcEngine Demo
Post by: 2112 on October 07, 2011, 10:05:27 PM
I tried to get this working in Python 2.6, but found it's not a trivial change.  For now this will only be compatible with Python 2.7
So, if I'm on Ubuntu 10.04 LTS on default repositories, is the Python 2.7 available for me without going the compile-your-own route?

I see 1227 packages with the word "python" in the name. As far as I can see there's only python 2.6 and python 3.1 to choose. Am I doing something wrong?


Title: Re: PBE BlockExplorer: a PyBtcEngine Demo
Post by: Remember remember the 5th of November on October 07, 2011, 10:09:45 PM
What about windows?


Title: Re: PBE BlockExplorer: a PyBtcEngine Demo
Post by: etotheipi on October 07, 2011, 10:16:35 PM
Sounds like I better work on getting this working in 2.6.  I didn't realize that 2.7 wasn't available in 10.04, and that's definitely a distro I want to support out-of-the-box.  I guess I'm learning about developing on a system that is too new.

As for Windows, I have a comment at the bottom of the original post.  I got swig to run and compiled the wrapper in MSVS.  But I can't seem to load PyQt4 or the SWIG'd module.  I was hoping someone might be able to help me figure out how to make it work.  There's no reason it wouldn't work, if I can just get python to load those things.



Title: Re: PBE BlockExplorer: a PyBtcEngine Demo
Post by: 2112 on October 07, 2011, 10:44:47 PM
Sounds like I better work on getting this working in 2.6.  I didn't realize that 2.7 wasn't available in 10.04, and that's definitely a distro I want to support out-of-the-box.
If you don't mind telling me: why you've choosen 2.7? What change in the Python language made your development easier?

I just looked into our build machines for the commercial software that we sell. Python versions were 2.2, 2.3 and 2.4. The software is selling rather well, and nobody asked us about "requiring support of newer version of Python". Our software is to the large extend like yours: finely tuned C++ engine plus an assortment of SWIG condoms I mean wrappers. What is that we are missing?

Do you mind telling me?


Title: Re: PBE BlockExplorer: a PyBtcEngine Demo
Post by: etotheipi on October 07, 2011, 11:13:30 PM
It wasn't a "choice" so to say, it's just what I have installed on my Ubuntu 11.04 system, and I started developing with it not realizing that some of the features I was using wouldn't be backwards compatible.  Similarly, I just went to the SWIG website and downloaded the latest version, and same with installing PyQt from the 11.04 repos.  I just use what's in front of me.  Perhaps I should be forcing myself to move back a few version of everything...

I'm not a software engineer, I'm a mathematician who writes algorithms for physics simulations, not in the realm of distributed end-user software.  There's a lot for me to learn about this process, but I'll get there eventually.  Until then, I'll have to backtrack a little bit to get this right. 


Title: Re: PBE BlockExplorer: a PyBtcEngine Demo
Post by: 2112 on October 07, 2011, 11:25:09 PM
It wasn't a "choice" so to say, it's just what I have installed on my Ubuntu 11.04 system, and I started developing with it not realizing that some of the features I was using wouldn't be backwards compatible.
Thank you very much. I really appreciate your answer.


Title: Re: PBE BlockExplorer: a PyBtcEngine Demo
Post by: etotheipi on October 09, 2011, 12:10:39 AM
Updated!  I not only added support for 2.6 (I think), but I added auto-updating when your client adds new blockdata to your blk0001.dat file.  

I tested on 10.04 in a VM, and got a strange display issue, not sure if it's real or not.  I'm sure you'll let me know :)  It's probably another feature I used not realizing it wasn't backwards compatible with non-bleeding-edge versions of PyQt.

Also updated the MSVS 2010 project, which successfully compiles everything and even runs SWIG as a pre-build event.  I still can't get PyQt4 or the resulting module loaded in a CLI session or script.  Perhaps the swig module has to be compiled into something other than a DLL?  I just got MSVS 2005 installed and will be setting up a project using that, soon.