Skip to content

Commit

Permalink
typo
Browse files Browse the repository at this point in the history
  • Loading branch information
zack-bitcoin committed Feb 8, 2017
1 parent 3f68f9b commit 3f11e02
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
12 changes: 8 additions & 4 deletions channel_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,19 @@ sleep 1

curl -i -d '["dice", 1000, [127,0,0,1], 3020]' http://localhost:3011 # "dice"
sleep 1

curl -i -d '["channel_solo_close", 2]' http://localhost:3011 # "dice"
sleep 1

#curl -i -d '["mine_block", 1, 1000000]' http://localhost:3021
#sleep 1

curl -i -d '["close_channel", [127,0,0,1], 3020]' http://localhost:3011
sleep 1
#curl -i -d '["close_channel", [127,0,0,1], 3020]' http://localhost:3011
#sleep 1
#curl -i -d '["mine_block", 1, 1000000]' http://localhost:3021
#sleep 1
curl -i -d '["sync", [127,0,0,1], 3010]' http://localhost:3021
sleep 1
#curl -i -d '["sync", [127,0,0,1], 3010]' http://localhost:3021
#sleep 1

#At the end of this test, the channel managers should still be storing the channels as if they were not closed. That way, if we are on a fork and it turns out the channel never got closed, we still have the channel data available to try closing again.
# Channel manager should have some sort of garbage collection to clean up old channels like this.
2 changes: 1 addition & 1 deletion src/consensus/txs/channel_solo_close.erl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
scriptpubkey(X) -> X#csc.scriptpubkey.

make(From, Fee, ScriptPubkey, ScriptSig, Accounts, Channels) ->
true = is_list(ScriptSig),
%true = is_list(ScriptSig),
CID = spk:cid(testnet_sign:data(ScriptPubkey)),
{_, Acc, Proof1} = account:get(From, Accounts),
{_, _Channel, Proofc} = channel:get(CID, Channels),
Expand Down
25 changes: 18 additions & 7 deletions src/networking/internal_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,24 @@ doit({dice, Amount, IP, Port}) ->
{ok, SSPK, OtherCommit} = talker:talk({dice, 1, MyID, Commit, Amount}, IP, Port),
SSPK2 = channel_feeder:agree_bet(dice, SSPK, [Amount, Commit, OtherCommit], Secret),%should store partner's info into channel manager.
SPK = testnet_sign:data(SSPK2),
SS1 = dice:make_ss(SPK, Secret),
{ok, SSPKsimple, TheirSecret} = talker:talk({dice, 2, MyID, SSPK2, SS1}, IP, Port), %SSPKsimple doesn't include the bet. the result of the bet instead is recorded.
SS = dice:resolve_ss(SPK, Secret, TheirSecret),%
SSPK2simple = channel_feeder:agree_simplification(dice, SSPKsimple, SS),
SPKsimple = testnet_sign:data(SSPKsimple),
SPKsimple = testnet_sign:data(SSPK2simple),
talker:talk({dice, 3, MyID, SSPK2simple}, IP, Port);
SS1 = dice:make_ss(SPK, Secret);
%{ok, SSPKsimple, TheirSecret} = talker:talk({dice, 2, MyID, SSPK2, SS1}, IP, Port), %SSPKsimple doesn't include the bet. the result of the bet instead is recorded.
%SS = dice:resolve_ss(SPK, Secret, TheirSecret),%
%SSPK2simple = channel_feeder:agree_simplification(dice, SSPKsimple, SS),
%SPKsimple = testnet_sign:data(SSPKsimple),
%SPKsimple = testnet_sign:data(SSPK2simple),
%talker:talk({dice, 3, MyID, SSPK2simple}, IP, Port);
doit({channel_solo_close, Other}) ->
Fee = free_constants:tx_fee(),
{Accounts,Channels,_,_} = tx_pool:data(),
{ok, CD} = channel_manager:read(Other),
SSPK = channel_feeder:them(CD),
SS = channel_feeder:script_sig_them(CD),
{Tx, _} = channel_solo_close:make(keys:id(), Fee, keys:sign(SSPK, Accounts), SS, Accounts, Channels),
STx = keys:sign(Tx, Accounts),
tx_pool_feeder:absorb(STx),
{ok, ok};

doit({add_peer, IP, Port}) ->
peers:add(IP, Port);
doit({sync, IP, Port}) ->
Expand Down

0 comments on commit 3f11e02

Please sign in to comment.