Skip to content

Commit

Permalink
Merge pull request tezos-reward-distributor-organization#122 from vDL…
Browse files Browse the repository at this point in the history
…-Digital-Ventures/merge_rpc

Merge lrpc and prpc and make the node choice more flexible
  • Loading branch information
jdsika authored Oct 26, 2019
2 parents c4c5c9f + 47a041a commit bb76917
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 536 deletions.
6 changes: 6 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ The most common use case is to run in mainnet and start to make payments from la
python3 src/main.py
```

TRD necessitates an interface to get provided with income and delegator data in order to perform the needed calculations.
The default provider is the public rpc node mainnet.tezrpc.me. However, it is possible to change the data provider with the flag -P rpc.
Please note that in this case, the default node would be localhost:8732. In order to change the node url for the provider, you can give the desired url
under the flag -A followed with node_url:port (e.g. -P rpc -A 127.0.0.1:8733).
Please note that the node should be an archive node, and that the port should be the rpc port specified while launching the node.

For more example commands please see wiki page:

https://github.com/habanoz/tezos-reward-distributor/wiki/How-to-Run
Expand Down
8 changes: 3 additions & 5 deletions src/api/provider_factory.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from rpc.lrpc_reward_api import LRpcRewardApiImpl
from rpc.prpc_reward_api import PRpcRewardApiImpl
from rpc.rpc_block_api import RpcBlockApiImpl
from rpc.rpc_reward_api import RpcRewardApiImpl
from tzscan.tzscan_mirror_selection_helper import TzScanMirrorSelector
Expand All @@ -16,12 +14,12 @@ def __init__(self, provider, verbose=False):
self.mirror_selector = None
self.verbose = verbose

def newRewardApi(self, network_config, baking_address, wllt_clnt_mngr, node_url):
def newRewardApi(self, network_config, baking_address, node_url):
if self.provider == 'rpc':
return LRpcRewardApiImpl(network_config, baking_address, node_url, wllt_clnt_mngr, validate=False, verbose=self.verbose)
return RpcRewardApiImpl(network_config, baking_address, node_url, protocol='http', validate=False, verbose=self.verbose)
elif self.provider == 'prpc':
url_prefix = self.url_prefixes[network_config['NAME']]
return PRpcRewardApiImpl(network_config, baking_address, self.URL.format(url_prefix), validate=False, verbose=self.verbose)
return RpcRewardApiImpl(network_config, baking_address, self.URL.format(url_prefix), protocol='https', validate=False, verbose=self.verbose)
elif self.provider == 'tzscan':
if not self.mirror_selector:
self.init_mirror_selector(network_config)
Expand Down
4 changes: 2 additions & 2 deletions src/calc/test_calculatePhase0.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from calc.calculate_phase0 import CalculatePhase0
from model import reward_log
from rpc.prpc_reward_api import PRpcRewardApiImpl
from api.provider_factory import ProviderFactory

BAKING_ADDRESS = "tz1Z1tMai15JWUWeN2PKL9faXXVPMuWamzJj"

Expand All @@ -14,7 +14,7 @@ def test_calculate(self):
nw = {'NAME': 'MAINNET', 'NB_FREEZE_CYCLE': 5, 'BLOCK_TIME_IN_SEC': 60, 'BLOCKS_PER_CYCLE': 4096,
'BLOCKS_PER_ROLL_SNAPSHOT': 256}

api = PRpcRewardApiImpl(nw, BAKING_ADDRESS, "mainnet.tezrpc.me")
api = ProviderFactory(provider='prpc').newRewardApi(nw, BAKING_ADDRESS, '')
model = api.get_rewards_for_cycle_map(153)

phase0 = CalculatePhase0(model)
Expand Down
2 changes: 1 addition & 1 deletion src/pay/payment_producer.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, name, initial_payment_cycle, network_config, payments_dir, ca

self.name = name

self.reward_api = provider_factory.newRewardApi(network_config, self.baking_address, wllt_clnt_mngr, node_url)
self.reward_api = provider_factory.newRewardApi(network_config, self.baking_address, node_url)
self.block_api = provider_factory.newBlockApi(network_config, wllt_clnt_mngr, node_url)

self.fee_calc = service_fee_calc
Expand Down
211 changes: 0 additions & 211 deletions src/rpc/lrpc_reward_api.py

This file was deleted.

Loading

0 comments on commit bb76917

Please sign in to comment.