Skip to content
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.

Commit

Permalink
Merge fc3a62c into f48f18e
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolaj Kuntner committed Aug 30, 2017
2 parents f48f18e + fc3a62c commit cf7ac21
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 93 deletions.
72 changes: 42 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p align="center">
<img
src="http://res.cloudinary.com/vidsy/image/upload/v1503160820/CoZ_Icon_DARKBLUE_200x178px_oq0gxm.png"
<img
src="http://res.cloudinary.com/vidsy/image/upload/v1503160820/CoZ_Icon_DARKBLUE_200x178px_oq0gxm.png"
width="125px;">
</p>

Expand All @@ -10,7 +10,6 @@
Python Node and SDK for the <b>NEO</b> blockchain.
</p>


<p align="center">
<a href="https://travis-ci.org/CityOfZion/neo-python">
<img src="https://travis-ci.org/CityOfZion/neo-python.svg?branch=master">
Expand All @@ -22,7 +21,8 @@

## What does it currently do

- This project aims to be a full port of the original C# [neo project](https://github.com/neo-project)
- This project aims to be a full port of the original C#
[neo project](https://github.com/neo-project)
- Run a python based P2P node
- Interactive CLI for configuring node and inspecting block chain
- Runs smart contracts on the block chain in a python virtual machine
Expand All @@ -34,64 +34,67 @@
- Compile smart contracts written python and deploy to blockchain
- Full smart contract debugging and inspection


### Get Help or give help

- Open a new [issue](https://github.com/CityOfZion/neo-python/issues/new) if you encounter a problem.
- Or ping **@localhuman** on the [NEO Slack](https://join.slack.com/t/neoblockchainteam/shared_invite/MjE3ODMxNDUzMDE1LTE1MDA4OTY3NDQtNTMwM2MyMTc2NA).
- Pull requests welcome. You can help with wallet functionality, writing tests or documentation, or on any other feature you deem awesome. All successful pull requests will be rewarded with one photo of a cat or kitten.

- Pull requests welcome. You can help with wallet functionality, writing tests or documentation, or on any other feature you deem awesome. All successful pull requests will be rewarded with one photo of a cat or kitten.

### License

- Open-source [Apache 2.0](https://github.com/CityOfZion/neo-python/blob/master/LICENSE).
- Main author is [@localhuman](https://github.com/localhuman).



## Getting started

you will need to install the libleveldb library.
You will need to install the libleveldb library.

##### on OSX:

```
brew install leveldb
```

##### ubuntu/debian

```
apt-get -s install libleveldb-dev
```

##### centos/redhat/fedora is a bit more tricky...
##### centos/redhat/fedora

This is a bit more tricky...

```
yum -y install development tools python35 python35-devel python35-pip readline-devel leveldb-devel libffi-devel
```

you may need to enable the epel repo for the leveldb-devel package, which you can do by editing `/etc/yum.repos.d/epel.repo`
You may need to enable the epel repo for the leveldb-devel package, which you can do by editing `/etc/yum.repos.d/epel.repo`.

### For all of these, make sure that the `Chains` directory in your project has the proper write permisisons
### For all of these, make sure that the `Chains` directory in your project has the proper write permissions

##### windows ( not sure )
##### Windows

Not sure. Installing the Python package plyvel seems to require C++ compiler support tied to Visual Studio and libraries.

-------------------

make a python 3 virtual environment, and activate it
Now navigate into the project, make a Python 3 virtual environment and activate
it via

```
python3 -m venv venv
source venv/bin/activate
```

then install requirements
Then install requirements
```
pip install -r requirements.txt
```


### Installing on OSX

if you're having an issue similar to this:
If you're having an issue similar to this:

```
from ._plyvel import ( # noqa
Expand All @@ -108,24 +111,34 @@ pip uninstall plyvel
CFLAGS='-mmacosx-version-min=10.7 -stdlib=libc++' pip install --no-use-wheel plyvel --no-cache-dir
```

## Running
Moreover, this pip installation must see the leveldb header file db.h.
You may need to add flags similar to the following to the
installation command

After installing requirements and activating your environment, there is an easy to use `prompt.py` file for you to run the node as well as some basic interactivity
```
--global-option=build_ext
--global-option="-I/usr/local/Cellar/leveldb/1.20_2/include/"
--global-option="-L/usr/local/lib"
```

## Running
After installing requirements and activating your environment, there is an easy
to use `prompt.py` file for you to run the node as well as some basic interactivity

```
python prompt.py
python prompt.py
NEO cli. Type 'help' to get started
neo> show state
Progress: 1054913 / 1237188
neo>
neo>
```

You can query for a block in the current server by hash or by block index:

```
python prompt.py
python prompt.py
NEO cli. Type 'help' to get started
neo> show block 122235
Expand All @@ -143,23 +156,20 @@ neo> show block 122235
"consensus data": 16070047272025254767,
"next_consensus": "59e75d652b5d3827bf04c165bbe9ef95cca4bf55"
}
neo>
neo>
```



#### Extra notes
On OSX, if you would like to run the process in the background, even when your computer is sleeping, you can use the built in `caffeinate` command

```
caffeinate python prompt.py
```


### Logging

Currently, `prompt.py` logs to `prompt.log`


## Tests

Tests are important. Currently there are not enough, but we are working on that. You can start them by running this command
Expand All @@ -171,15 +181,17 @@ When running tests the first time, the test setup will try to download the file
Long story short, the first time you run your tests, it will take a while to download those fixtures. After that it should be pretty quick.

```
python -m unittest discover neo
python -m unittest discover neo
```

To run tests with `coverage`, use the following
To run tests with `coverage`, use the following

```
coverage run -m unittest discover neo
```

After that, you can generate a command line coverage report use the following:

```
coverage report -m --omit=venv/*
```
6 changes: 3 additions & 3 deletions neo/Defaults.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os

TEST_NODE = "http://seed1.antshares.org:20333/"
TEST_NODE = 'http://seed1.antshares.org:20333/'
TEST_ADDRESS = 'AFsRovA3GyLznpAyAYXiv8ZwDswKj1g5A2'

LDB_PATH= '/tmp/'
LDB_PATH = '/tmp/'

PEEWEE_DB ='accounts.db'
PEEWEE_DB = 'accounts.db'
2 changes: 2 additions & 0 deletions neo/Exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ def __init__(self, info):
super(Exception, self).__init__(info)
self.error_code = 0x0002


class OutputError(Exception):
"""Output Error"""
def __init__(self, info):
super(Exception, self).__init__(info)
self.error_code = 0x0003


class RegisterNameError(Exception):
"""Regiser Transaction Name Error"""
def __init__(self, info):
Expand Down
2 changes: 1 addition & 1 deletion neo/Helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def big_or_little(string):
arr[idx], arr[length - idx] = arr[length - idx], arr[idx]
return bytes(arr)


def big_or_little_str(string):
arr = bytearray(string)
length = len(arr)
Expand All @@ -27,4 +28,3 @@ def big_or_little_str(string):
else:
arr[index], arr[length -index] = arr[length -index], arr[index]
return str(arr)

0 comments on commit cf7ac21

Please sign in to comment.