This repository has been archived by the owner on Aug 22, 2019. It is now read-only.
Implement child chain and client #26
Merged
DavidKnott
merged 14 commits into
omgnetwork:master
from
DavidKnott:implement-child-chain
Feb 28, 2018
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5b8013f
Create child chain
DavidKnott e65b19f
Test block
DavidKnott f1ec246
Update cli command and ethereum version
DavidKnott 48e68c5
Update block
DavidKnott 00b60f0
Add confirmations to transaction
DavidKnott ed65774
Create transaction confirmations
DavidKnott bd9a53d
Create child chain
DavidKnott 4b1e50d
Create client
DavidKnott 0fae799
Create command line interface
DavidKnott f8c2662
Update config
DavidKnott a4a6a18
Add inits
DavidKnott ddf2edd
Update block tests
DavidKnott 0a3ce89
Update readme and install requirements
DavidKnott 6942475
Clean up child chain implementation
DavidKnott File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,12 +20,8 @@ def start_client_cmd(ctx): | |
|
||
class ClientParser(): | ||
|
||
def __init__(self): | ||
self.client = Client() | ||
self.db = plyvel.DB('/tmp/plasma_mvp_db/', create_if_missing=True) | ||
self.current_block = self.client.get_current_block_num() | ||
self.synced_block = 1 | ||
self.client_cmds = dict( | ||
synced_block = 1 | ||
client_cmds = dict( | ||
sync=self.sync_child_chain, | ||
deposit=self.deposit, | ||
send_tx=self.send_tx, | ||
|
@@ -34,13 +30,18 @@ def __init__(self): | |
help=self.help, | ||
) | ||
|
||
def __init__(self): | ||
self.client = Client() | ||
self.db = plyvel.DB('/tmp/plasma_mvp_db/', create_if_missing=True) | ||
self.current_block = self.client.get_current_block_num() | ||
|
||
def process_input(self, inp): | ||
self.inp = inp | ||
command = self.inp[0] | ||
if command not in self.client_cmds: | ||
if command not in client_cmds: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We still need the |
||
print("Please enter a valid command ('or enter help')") | ||
else: | ||
return self.client_cmds[command]() | ||
return client_cmds[command]() | ||
|
||
def sync_child_chain(self): | ||
self.current_block = self.client.get_current_block_num() | ||
|
@@ -77,9 +78,7 @@ def send_tx(self): | |
amount2 = int(self.inp[10]) | ||
fee = int(self.inp[11]) | ||
key1 = utils.normalize_key(self.inp[12]) | ||
key2 = b'' | ||
if len(self.inp) == 14: | ||
key2 = utils.normalize_key(self.inp[13]) | ||
key2 = utils.normalize_key(self.inp[13]) if len(self.inp) == 14 else b'' | ||
tx = Transaction(blknum1, tx_pos1, utxo_pos1, | ||
blknum2, tx_pos2, utxo_pos2, | ||
newowner1, amount1, | ||
|
@@ -106,9 +105,7 @@ def withdraw(self): | |
blknum, txindex, oindex = int(self.inp[1]), int(self.inp[2]), int(self.inp[3]) | ||
txPos = [blknum, txindex, oindex] | ||
key1 = utils.normalize_key(self.inp[4]) | ||
key2 = b'' | ||
if len(self.inp) == 6: | ||
key2 = utils.normalize_key(self.inp[5]) | ||
key2 = utils.normalize_key(self.inp[5]) if len(self.inp) == 6 else b'' | ||
block = self.client.get_block(blknum) | ||
block = rlp.decode(utils.decode_hex(block), Block) | ||
tx = block.transaction_set[txindex] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,8 +22,7 @@ def send_request(self, method, args): | |
"jsonrpc": "2.0", | ||
"id": 0, | ||
} | ||
response = requests.post(self.url, data=json.dumps(payload), | ||
headers=headers).json() | ||
response = requests.post(self.url, data=payload).json() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
return response["result"] | ||
|
||
def submit_deposit(self, tx_hash): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving
client_cmds
to a class variable means we don't have access toself
so we need to change to: