Skip to content

Commit

Permalink
Merge branch 'release/v0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
etienne-napoleone committed Dec 4, 2018
2 parents 613b474 + 01c3557 commit c12bfc0
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 47 deletions.
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Tomo MasterNode (tmn) is a cli tool to help you run a TomoChain masternode
## Running and applying a masternode

If you are consulting this repo, it's probably because you want to run a masternode.
For complete guidelines on running a full node and applying it as a masternode, please refer to the [documentation](https://docs.tomochain.com/get-started/run-node/).
For complete guidelines on running a masternode candidate, please refer to the [documentation](https://docs.tomochain.com/masternode/requirements/).

## Requirements

- Python >= 3.5
- Python >= 3.5.3
- Docker

## Installation
Expand All @@ -23,11 +23,15 @@ For complete guidelines on running a full node and applying it as a masternode,
pip3 install --user tmn
```

If you are using macOS, make sure that the user python3 path is in your `$PATH`.
Make sure to have the user's python binaries folder in your `$PATH`.

They are in `~/Library/Python/[python version number]/bin`.
**For GNU/Linux**:

For example, with python `3.6` and `bash`, add `PATH=$PATH:$HOME/Library/Python/3.6/bin` to your `$HOME/.bashrc`.
`echo "PATH=$PATH:$HOME/.local/bin/" > $HOME/.bashrc`

**For macOS**:

`echo "PATH=$PATH:$HOME/Library/Python/3.6/bin" > $HOME/.bashrc`

## Update

Expand Down Expand Up @@ -84,6 +88,13 @@ pkey = a25...5f5 # The private key of the account you want your
tmn start --name $name --net $net --pkey $pkey
```


**Note**:

You can expose the RPC and WS api by appending the flag `--api`.
Be warned that it should not be directly exposed to outside.
It is your responsability to firewall those ports for internal use or reverse proxy it with an http server like nginx.

### After the first start

Once your node has been configured, you can use the start, stop and
Expand Down
56 changes: 28 additions & 28 deletions pyproject.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
[tool.poetry]
name = "tmn"
version = "0.3.2"
version = "0.4.0"
description = "Quickstart your masternode"
readme = "README.md"
license = "GPL-3.0+"
homepage = "https://tomochain.com"
repository = "https://github.com/tomochain/masternode"
documentation = "https://github.com/tomochain/masternode/blob/master/README.md"
repository = "https://github.com/tomochain/tmn"
documentation = "https://docs.tomochain.com/masternode/tmn/"
keywords = ["tomochain", "blockchain", "masternode", "node"]
authors = [
"Etienne Napoleone <etienne@tomochain.com>"
]

[tool.poetry.dependencies]
python = "^3.5.3"
docker = "3.5.0"
python = ">=3.5.3"
docker = "^3.5.0"
pastel = "^0.1.0"
clint = "^0.5.1"
python-slugify = "^1.2"
Expand Down
4 changes: 2 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def _clean(tmn):


def test_version(runner, tmn):
version = '0.3.2'
version = '0.4.0'
result = runner.invoke(tmn.main, ['--version'])
assert result.output[-6:-1] == version
assert package.__version__ == version
Expand All @@ -85,7 +85,7 @@ def test_command(runner, tmn):
def test_command_docs(runner, tmn):
result = runner.invoke(tmn.main, ['docs'])
msg = 'Documentation on running a masternode:'
link = 'https://docs.tomochain.com/get-started/run-node\n'
link = 'https://docs.tomochain.com/masternode/tmn/\n'
assert result.output == "{} {}".format(msg, link)
assert result.exit_code == 0

Expand Down
2 changes: 1 addition & 1 deletion tmn/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging

__version__ = '0.3.2'
__version__ = '0.4.0'

handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter('[%(levelname)s] %(message)s'))
Expand Down
14 changes: 11 additions & 3 deletions tmn/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Configuration:

def __init__(self, name: str = None, net: str = None,
pkey: str = None, start: bool = False,
docker_url: str = None) -> None:
docker_url: str = None, api: bool = False) -> None:
self.networks = {}
self.services = {}
self.volumes = {}
Expand All @@ -34,6 +34,7 @@ def __init__(self, name: str = None, net: str = None,
self.client = docker.from_env()
else:
self.client = docker.DockerClient(base_url=docker_url)
self.api = 'True' if api else 'False'
try:
self.client.ping()
except Exception as e:
Expand All @@ -59,6 +60,7 @@ def _load(self) -> None:
self.id = resources.user.read('id')
self.name = resources.user.read('name')
self.net = resources.user.read('net')
self.api = resources.user.read('api')
#######################################################################
# this is a dirty fix for retro compatiblity #
# can be removed in some future version #
Expand Down Expand Up @@ -86,6 +88,7 @@ def _write(self) -> None:
resources.user.write('id', self.id)
resources.user.write('name', self.name)
resources.user.write('net', self.net)
resources.user.write('api', self.api)

def _compose(self) -> None:
self.networks['tmn'] = Network(
Expand All @@ -101,7 +104,12 @@ def _compose(self) -> None:
elif self.net == 'testnet':
tag = 'testnet'
else:
tag = 'latest'
tag = 'devnet'
if self.api == 'True': # this is dirty, should be refactored
tomochain_ports = {'30303/udp': 30303, '30303/tcp': 30303,
8545: 8545, 8546: 8546}
else:
tomochain_ports = {'30303/udp': 30303, '30303/tcp': 30303}
self.services['metrics'] = Service(
name='{}_metrics'.format(self.name),
hostname='{}'.format(self.id),
Expand Down Expand Up @@ -130,7 +138,7 @@ def _compose(self) -> None:
'bind': '/tomochain', 'mode': 'rw'
}
},
ports={'30303/udp': 30303, '30303/tcp': 30303},
ports=tomochain_ports,
client=self.client
)
for container, variables in environments[self.net].items():
Expand Down
2 changes: 1 addition & 1 deletion tmn/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
pastel.add_style('warning', 'yellow')
pastel.add_style('error', 'red')

help_url = 'https://docs.tomochain.com/get-started/run-node'
help_url = 'https://docs.tomochain.com/masternode/tmn/'


def newline(number: int = 1) -> None:
Expand Down
5 changes: 3 additions & 2 deletions tmn/tmn.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ def docs() -> None:
@click.option('--pkey', metavar='KEY', help=('Private key of the account your '
'masternode will collect rewards '
'on'))
def start(name: str, net: str, pkey: str) -> None:
@click.option('--api', is_flag=True)
def start(name: str, net: str, pkey: str, api: bool) -> None:
"Start the containers needed to run a masternode"
configuration = Configuration(name=name, net=net, pkey=pkey, start=True,
docker_url=docker_url)
docker_url=docker_url, api=api)
if configuration.force_recreate:
display.error_breaking_change()
sys.exit('\n')
Expand Down

0 comments on commit c12bfc0

Please sign in to comment.