Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
didi
github_repo_test
Commits
0866c0a4
Commit
0866c0a4
authored
Aug 08, 2017
by
didi
Browse files
started addressing circular dependencies (not yet correctly implemented), refs #2
parent
5a6340b7
Changes
4
Hide whitespace changes
Inline
Side-by-side
backend/contracts/Streem.sol
View file @
0866c0a4
// TODO: use the SafeMath lib of openzeppelin (implicit overflow checks etc)?
// TODO: use the SafeMath lib of openzeppelin (implicit overflow checks etc)?
// TODO: check if this complies with the recommended style: http://solidity.readthedocs.io/en/develop/style-guide.html
pragma
solidity
^
0.4
.
11
;
pragma
solidity
^
0.4
.
11
;
...
@@ -32,6 +33,7 @@ contract Streem {
...
@@ -32,6 +33,7 @@ contract Streem {
*/
*/
mapping
(
address
=>
uint
)
outStreamPtrs
;
mapping
(
address
=>
uint
)
outStreamPtrs
;
mapping
(
address
=>
uint
)
inStreamPtrs
;
mapping
(
address
=>
uint
)
inStreamPtrs
;
// TODO: convert to mapping (better suited when elements are deleted)
Stream
[]
streams
;
Stream
[]
streams
;
event
Transfer
(
address
indexed
_from
,
address
indexed
_to
,
uint256
_value
);
event
Transfer
(
address
indexed
_from
,
address
indexed
_to
,
uint256
_value
);
...
@@ -64,7 +66,7 @@ contract Streem {
...
@@ -64,7 +66,7 @@ contract Streem {
// returns the settled balance and the outstanding balance (> 0 if underfunded)
// returns the settled balance and the outstanding balance (> 0 if underfunded)
function
settleStream
(
Stream
s
)
internal
returns
(
uint
,
uint
)
{
function
settleStream
(
Stream
s
)
internal
returns
(
uint
,
uint
)
{
var
bal
=
streamBalance
(
s
);
var
bal
=
streamBalance
(
s
,
s
,
1
);
uint
dt
=
uint
(
bal
/
s
.
perSecond
);
uint
dt
=
uint
(
bal
/
s
.
perSecond
);
// since we don't allow fractional seconds, the possible settleBalance may be lower than the actual streamBalance (TODO: sure?)
// since we don't allow fractional seconds, the possible settleBalance may be lower than the actual streamBalance (TODO: sure?)
var
settleBal
=
dt
*
s
.
perSecond
;
var
settleBal
=
dt
*
s
.
perSecond
;
...
@@ -141,6 +143,11 @@ contract Streem {
...
@@ -141,6 +143,11 @@ contract Streem {
delete
streams
[
sid
];
delete
streams
[
sid
];
}
}
function
equals
(
Stream
s1
,
Stream
s2
)
internal
constant
returns
(
bool
)
{
// TODO: not multi-stream ready
return
s1
.
sender
==
s2
.
sender
&&
s1
.
receiver
==
s2
.
receiver
;
}
// returns the naive "should be" balance of a stream, ignoring the possibility of it running out of funds
// returns the naive "should be" balance of a stream, ignoring the possibility of it running out of funds
function
naiveStreamBalance
(
Stream
s
)
internal
constant
returns
(
uint256
)
{
function
naiveStreamBalance
(
Stream
s
)
internal
constant
returns
(
uint256
)
{
return
(
now
-
s
.
startTimestamp
)
*
s
.
perSecond
;
return
(
now
-
s
.
startTimestamp
)
*
s
.
perSecond
;
...
@@ -152,19 +159,23 @@ contract Streem {
...
@@ -152,19 +159,23 @@ contract Streem {
* Implements min(outgoingStreamBalance, staticBalance + incomingStreamBalance)
* Implements min(outgoingStreamBalance, staticBalance + incomingStreamBalance)
* TODO: due to the involved recursion, this will lead to an endless loop in circular relations, e.g. A -> B, B -> A
* TODO: due to the involved recursion, this will lead to an endless loop in circular relations, e.g. A -> B, B -> A
*/
*/
function
streamBalance
(
Stream
s
)
internal
constant
returns
(
uint256
)
{
function
streamBalance
(
Stream
s
,
Stream
origin
,
uint
hops
)
internal
constant
returns
(
uint256
)
{
// naming: osb -> outgoingStreamBalance, isb -> incomingStreamBalance, sb -> static balance
// naming: osb -> outgoingStreamBalance, isb -> incomingStreamBalance, sb -> static balance
uint256
osb
=
naiveStreamBalance
(
s
);
uint256
osb
=
naiveStreamBalance
(
s
);
var
inS
=
getInStreamOf
(
s
.
sender
);
if
(
equals
(
s
,
origin
))
{
// special case: break on circular dependency. TODO: proof correctness
uint256
isb
=
exists
(
inS
)
?
streamBalance
(
inS
)
:
0
;
return
osb
;
}
else
{
var
inS
=
getInStreamOf
(
s
.
sender
);
uint256
isb
=
exists
(
inS
)
?
streamBalance
(
inS
,
origin
,
hops
+
1
)
:
0
;
int
sb
=
settledBalances
[
s
.
sender
];
int
sb
=
settledBalances
[
s
.
sender
];
// TODO: Proof needed
// TODO: Proof needed
assert
(
sb
+
int
(
isb
)
>=
0
);
assert
(
sb
+
int
(
isb
)
>=
0
);
return
min
(
osb
,
uint
(
sb
+
int
(
isb
)));
return
min
(
osb
,
uint
(
sb
+
int
(
isb
)));
}
}
}
// this balance function can return a negative value if an outgoing stream went "under water"
// this balance function can return a negative value if an outgoing stream went "under water"
...
@@ -193,10 +204,10 @@ contract Streem {
...
@@ -193,10 +204,10 @@ contract Streem {
function
balanceOf
(
address
_owner
)
constant
returns
(
uint256
)
{
function
balanceOf
(
address
_owner
)
constant
returns
(
uint256
)
{
var
inS
=
getInStreamOf
(
_owner
);
var
inS
=
getInStreamOf
(
_owner
);
// no prettier null check possible? https://ethereum.stackexchange.com/questions/871/what-is-the-zero-empty-or-null-value-of-a-struct
// no prettier null check possible? https://ethereum.stackexchange.com/questions/871/what-is-the-zero-empty-or-null-value-of-a-struct
uint256
inStreamBal
=
exists
(
inS
)
?
streamBalance
(
inS
)
:
0
;
uint256
inStreamBal
=
exists
(
inS
)
?
streamBalance
(
inS
,
inS
,
1
)
:
0
;
var
outS
=
getOutStreamOf
(
_owner
);
var
outS
=
getOutStreamOf
(
_owner
);
uint256
outStreamBal
=
exists
(
outS
)
?
streamBalance
(
outS
)
:
0
;
uint256
outStreamBal
=
exists
(
outS
)
?
streamBalance
(
outS
,
outS
,
1
)
:
0
;
// TODO: check overflow before casting
// TODO: check overflow before casting
assert
(
settledBalances
[
_owner
]
+
int
(
inStreamBal
)
-
int
(
outStreamBal
)
>=
0
);
assert
(
settledBalances
[
_owner
]
+
int
(
inStreamBal
)
-
int
(
outStreamBal
)
>=
0
);
...
...
frontend/js/streem_contract.js
View file @
0866c0a4
...
@@ -317,7 +317,7 @@ const contract = {
...
@@ -317,7 +317,7 @@ const contract = {
"
type
"
:
"
event
"
"
type
"
:
"
event
"
}
}
],
],
"
unlinked_binary
"
:
"
0x6060604052341561000f57600080fd5b604051602080611
07f
833981016040528080519150505b60018054600160a060020a03191633600160a060020a03169081178255600090815260026020526040812083905582905560058054909181016100698382610103565b916000526020600020906004020160005b60806040519081016040908152600080835260208301819052908201819052606082015291905081518154600160a060020a031916600160a060020a03919091161781556020820151600182018054600160a060020a031916600160a060020a039290921691909117905560408201518160020155606082015181600301555050505b5061017b565b81548183558181151161012f5760040281600402836000526020600020918201910161012f9190610135565b5b505050565b61017891905b80821115610174578054600160a060020a031990811682556001820180549091169055600060028201819055600382015560040161013b565b5090565b90565b610
ef5
8061018a6000396000f300606060405236156100d85763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100dd57806318160ddd14610168578063313ce5671461018d5780635cc8ce33146101b657806364a80c0c146101db57806370a08231146101ff5780637ae2b5c71461023057806395d89b411461025b5780639dad9382146102e6578063a1365fda146102fb578063a9059cbb14610320578063e13e2ecf14610344578063e61b959e14610368578063e8f88890146103b1578063f408ebe9146103fa575b600080fd5b34156100e857600080fd5b6100f061040f565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561012d5780820151818401525b602001610114565b50505050905090810190601f16801561015a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561017357600080fd5b61017b610446565b60405190815260200160405180910390f35b341561019857600080fd5b6101a061044c565b60405160ff909116815260200160405180910390f35b34156101c157600080fd5b61017b610451565b60405190815260200160405180910390f35b34156101e657600080fd5b6101fd600160a060020a036004351660243561046e565b005b341561020a57600080fd5b61017b600160a060020a03600435166105f8565b60405190815260200160405180910390f35b341561023b57600080fd5b61017b600435602435610
794
565b60405190815260200160405180910390f35b341561026657600080fd5b6100f0610
7ae
565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561012d5780820151818401525b602001610114565b50505050905090810190601f16801561015a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156102f157600080fd5b6101fd610
7e5
565b005b341561030657600080fd5b61017b610
8fc
565b60405190815260200160405180910390f35b341561032b57600080fd5b6101fd600160a060020a03600435166024356109
03
565b005b341561034f57600080fd5b6101fd600160a060020a0360043516602435610
98d
565b005b341561037357600080fd5b61037b610
9d1
565b6040518084600160a060020a0316600160a060020a03168152602001838152602001828152602001935050505060405180910390f35b34156103bc57600080fd5b61037b610a
0b
565b6040518084600160a060020a0316600160a060020a03168152602001838152602001828152602001935050505060405180910390f35b341561040557600080fd5b6101fd610a
42
565b005b60408051908101604052600681527f53747265656d0000000000000000000000000000000000000000000000000000602082015281565b60005481565b600081565b600160a060020a0333166000908152600260205260409020545b90565b60006104bc61047c33610b
4e
565b608060405190810160409081528254600160a060020a03908116835260018401541660208301526002830154908201526003909101546060820152610
b90
565b156104c357fe5b60006104ce336105f8565b10156104d657fe5b6001600580548060010182816104ec9190610
e2c
565b916000526020600020906004020160005b60806040519081016040908152600160a060020a03338116835289166020830152810187905242606082015291905081518154600160a060020a031916600160a060020a03919091161781556020820151600182018054600160a060020a031916600160a060020a0392909216919091179055604082015181600201556060820151600391820155600160a060020a03338116600081815260209384526040808220979096039687905591891680835260049093529084902085905593945092917f4baaa557c21346b70bdc9482890b5d7e315f6a2123611e74004857ebecde0686915085905190815260200160405180910390a35b505050565b600080600080600061060986610
ba1
565b935061064f84608060405190810160409081528254600160a060020a03908116835260018401541660208301526002830154908201526003909101546060820152610
b90
565b61065a5760006106
9
e565b6106
9
e84608060405190810160409081528254600160a060020a03908116835260018401541660208301526002830154
9082015260039091
01546060820152610
be3
565b5b92506106
aa
86610b
4e
565b9150610
6f0
82608060405190810160409081528254600160a060020a03908116835260018401541660208301526002830154908201526003909101546060820152610
b90
565b610
6fb
5760006107
3f
565b6107
3f
82608060405190810160409081528254600160a060020a03908116835260018401541660208301526002830154
9082015260039091
01546060820152610
be3
565b5b600160a060020a03871660009081526002602052604081205491925090840182900312156107
6a
57fe5b600160a060020a038616600090815260026020526040902054830181900394505b50505050919050565b6000818310610
7a3
5781610
7a5
565b825b90505b92915050565b60408051908101604052600381527f5354520000000000000000000000000000000000000000000000000000000000602082015281565b6000806000610
7f3
33610b
4e
565b92506108
39
83608060405190810160409081528254600160a060020a03908116835260018401541660208301526002830154908201526003909101546060820152610
b90
565b15156108
41
57fe5b610
885
83608060405190810160409081528254600160a060020a03908116835260018401541660208301526002830154908201526003909101546060820152610
cdf
565b60018501546002860154929450909250600160a060020a039081169133909116907f96c5271ec05cb2683bdc50cf109341f5a4e45b02907df1c23a8855bddbe030a190858560405180848152602001838152602001828152602001935050505060405180910390a36105f333610
da
d565b5b505050565b6005545b90565b6000811180156109
1b
5750806109
18
336105f8565b10155b15156109
23
57fe5b600160a060020a033381166000818152600260205260408082208054869003905592851680825290839020805485019055917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9084905190815260200160405180910390a35b5050565b60015433600160a060020a03908116911614610
9a8
57600080fd5b600160a060020a03821660009081526002602052604081208054830190558054820190555b5050565b600080600080610
9e0
33610b
4e
565b600181015460028201546003830154600160a060020a03909216965094504203925090505b50909192565b600080600080610a
1
a33610
ba1
565b805460028201546003830154600160a060020a03909216965094504203925090505b50909192565b600160a060020a0333811660008181526002602090815260408083208390556003825280832083905560049091528120556001549091161415610b
4b
5760008054600160a060020a033316825260026020526040822055610
aa5
90600590610
e5e
565b6005805460018101610
ab7
8382610
e2c
565b916000526020600020906004020160005b60806040519081016040908152600080835260208301819052908201819052606082015291905081518154600160a060020a031916600160a060020a03919091161781556020820151600182018054600160a060020a031916600160a060020a039290921691909117905560408201518160020155606082015181600301555050505b5b565b600160a060020a038116600090815260036020526040812054600580549091908110610b
76
57fe5b906000526020600020906004020160005b5090505b919050565b60008160600151151590505b919050565b600160a060020a038116600090815260046020526040812054600580549091908110610b
76
57fe5b906000526020600020906004020160005b5090505b919050565b6000806000806000610
bf486
610e
1
5565b9350610c
008651610ba1
565b9250610c
46
83608060405190810160409081528254600160a060020a03908116835260018401541660208301526002830154908201526003909101546060820152610
b90
565b610c
51
576000610
c95
565b610
c95
83608060405190810160409081528254600160a060020a03908116835260018
4
01541660208
3
015260028
3
01549
0820
1526003909
1
01546060820152
610be3
565b5b9150600260008
7
51600160a060020a03168152602081019190915260400160009081205491508282011215610
cc7
57fe5b610
cd3
84838301610
794
565b94505b505050509
19
050565b600080600080600080610
cf
187
610be3
565b9350866040015184811515610d
0
257fe5b049250866040015183029150610d
1
787610e
1
5565b905081600260008951600160a060020a0316600160a060020a031681526020019081526020016000206000828254039250508190555081600260008960200151600160a060020a031681526020810191909152604001600020805490910190558260608801818151019052504260608801511115610
d9
157fe5b80821115610
d9
b57fe5b81828203955095505b50505050915091565b600160a060020a0381166000908152600360205260409020546005805482908110610
dd
457fe5b906000526020600020906004020160005b508054600160a060020a0319908116825560018201805490911690556000600282018190556003909101555b5050565b60008160400151826060015142030290505b919050565b8154818355818115116105f3576004028160040283600052602060002091820191016105f39190610
e83
565b5b505050565b5080546000825560040290600052602060002090810190610
e7f
9190610
e83
565b5b50565b61046b91905b80821115610
ec2
578054600160a060020a0319908116825560018201805490911690556000600282018190556003820155600401610
e89
565b5090565b905600a165627a7a72305820
d00c5aac227632ff138d1a4fa835789fdf6e37adb194ce535e3394712417a679
0029
"
,
"
unlinked_binary
"
:
"
0x6060604052341561000f57600080fd5b604051602080611
176
833981016040528080519150505b60018054600160a060020a03191633600160a060020a03169081178255600090815260026020526040812083905582905560058054909181016100698382610103565b916000526020600020906004020160005b60806040519081016040908152600080835260208301819052908201819052606082015291905081518154600160a060020a031916600160a060020a03919091161781556020820151600182018054600160a060020a031916600160a060020a039290921691909117905560408201518160020155606082015181600301555050505b5061017b565b81548183558181151161012f5760040281600402836000526020600020918201910161012f9190610135565b5b505050565b61017891905b80821115610174578054600160a060020a031990811682556001820180549091169055600060028201819055600382015560040161013b565b5090565b90565b610
fec
8061018a6000396000f300606060405236156100d85763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100dd57806318160ddd14610168578063313ce5671461018d5780635cc8ce33146101b657806364a80c0c146101db57806370a08231146101ff5780637ae2b5c71461023057806395d89b411461025b5780639dad9382146102e6578063a1365fda146102fb578063a9059cbb14610320578063e13e2ecf14610344578063e61b959e14610368578063e8f88890146103b1578063f408ebe9146103fa575b600080fd5b34156100e857600080fd5b6100f061040f565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561012d5780820151818401525b602001610114565b50505050905090810190601f16801561015a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561017357600080fd5b61017b610446565b60405190815260200160405180910390f35b341561019857600080fd5b6101a061044c565b60405160ff909116815260200160405180910390f35b34156101c157600080fd5b61017b610451565b60405190815260200160405180910390f35b34156101e657600080fd5b6101fd600160a060020a036004351660243561046e565b005b341561020a57600080fd5b61017b600160a060020a03600435166105f8565b60405190815260200160405180910390f35b341561023b57600080fd5b61017b600435602435610
81c
565b60405190815260200160405180910390f35b341561026657600080fd5b6100f0610
836
565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561012d5780820151818401525b602001610114565b50505050905090810190601f16801561015a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156102f157600080fd5b6101fd610
86d
565b005b341561030657600080fd5b61017b610
984
565b60405190815260200160405180910390f35b341561032b57600080fd5b6101fd600160a060020a03600435166024356109
8b
565b005b341561034f57600080fd5b6101fd600160a060020a0360043516602435610
a15
565b005b341561037357600080fd5b61037b610
a59
565b6040518084600160a060020a0316600160a060020a03168152602001838152602001828152602001935050505060405180910390f35b34156103bc57600080fd5b61037b610a
93
565b6040518084600160a060020a0316600160a060020a03168152602001838152602001828152602001935050505060405180910390f35b341561040557600080fd5b6101fd610a
ca
565b005b60408051908101604052600681527f53747265656d0000000000000000000000000000000000000000000000000000602082015281565b60005481565b600081565b600160a060020a0333166000908152600260205260409020545b90565b60006104bc61047c33610b
d6
565b608060405190810160409081528254600160a060020a03908116835260018401541660208301526002830154908201526003909101546060820152610
c18
565b156104c357fe5b60006104ce336105f8565b10156104d657fe5b6001600580548060010182816104ec9190610
f23
565b916000526020600020906004020160005b60806040519081016040908152600160a060020a03338116835289166020830152810187905242606082015291905081518154600160a060020a031916600160a060020a03919091161781556020820151600182018054600160a060020a031916600160a060020a0392909216919091179055604082015181600201556060820151600391820155600160a060020a03338116600081815260209384526040808220979096039687905591891680835260049093529084902085905593945092917f4baaa557c21346b70bdc9482890b5d7e315f6a2123611e74004857ebecde0686915085905190815260200160405180910390a35b505050565b600080600080600061060986610
c29
565b935061064f84608060405190810160409081528254600160a060020a03908116835260018401541660208301526002830154908201526003909101546060820152610
c18
565b61065a5760006106e
2
565b6106e
2
84608060405190810160409081528254600160a060020a03908116835260018401541660208301526002830154
8183015260039092015460608201529086906080905190810160409081528254600160a060020a039081168352600180850154909116602084015260028401549183019190915260039092
01546060820152
90
610
c6b
565b5b92506106
ee
86610b
d6
565b9150610
734
82608060405190810160409081528254600160a060020a03908116835260018401541660208301526002830154908201526003909101546060820152610
c18
565b610
73f
5760006107
c7
565b6107
c7
82608060405190810160409081528254600160a060020a03908116835260018401541660208301526002830154
8183015260039092015460608201529084906080905190810160409081528254600160a060020a039081168352600180850154909116602084015260028401549183019190915260039092
01546060820152
90
610
c6b
565b5b600160a060020a03871660009081526002602052604081205491925090840182900312156107
f2
57fe5b600160a060020a038616600090815260026020526040902054830181900394505b50505050919050565b6000818310610
82b
5781610
82d
565b825b90505b92915050565b60408051908101604052600381527f5354520000000000000000000000000000000000000000000000000000000000602082015281565b6000806000610
87b
33610b
d6
565b92506108
c1
83608060405190810160409081528254600160a060020a03908116835260018401541660208301526002830154908201526003909101546060820152610
c18
565b15156108
c9
57fe5b610
90d
83608060405190810160409081528254600160a060020a03908116835260018401541660208301526002830154908201526003909101546060820152610
d8c
565b60018501546002860154929450909250600160a060020a039081169133909116907f96c5271ec05cb2683bdc50cf109341f5a4e45b02907df1c23a8855bddbe030a190858560405180848152602001838152602001828152602001935050505060405180910390a36105f333610
e5
d565b5b505050565b6005545b90565b6000811180156109
a3
5750806109
a0
336105f8565b10155b15156109
ab
57fe5b600160a060020a033381166000818152600260205260408082208054869003905592851680825290839020805485019055917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9084905190815260200160405180910390a35b5050565b60015433600160a060020a03908116911614610
a30
57600080fd5b600160a060020a03821660009081526002602052604081208054830190558054820190555b5050565b600080600080610
a68
33610b
d6
565b600181015460028201546003830154600160a060020a03909216965094504203925090505b50909192565b600080600080610aa
2
33610
c29
565b805460028201546003830154600160a060020a03909216965094504203925090505b50909192565b600160a060020a0333811660008181526002602090815260408083208390556003825280832083905560049091528120556001549091161415610b
d3
5760008054600160a060020a033316825260026020526040822055610
b2d
90600590610
f55
565b6005805460018101610
b3f
8382610
f23
565b916000526020600020906004020160005b60806040519081016040908152600080835260208301819052908201819052606082015291905081518154600160a060020a031916600160a060020a03919091161781556020820151600182018054600160a060020a031916600160a060020a039290921691909117905560408201518160020155606082015181600301555050505b5b565b600160a060020a038116600090815260036020526040812054600580549091908110610b
fe
57fe5b906000526020600020906004020160005b5090505b919050565b60008160600151151590505b919050565b600160a060020a038116600090815260046020526040812054600580549091908110610b
fe
57fe5b906000526020600020906004020160005b5090505b919050565b6000806000806000610
c7c88
610e
c
5565b9350610c
888888610edc565b15610c9557839450610d80565b610c9f8851610c29
565b9250610c
e5
83608060405190810160409081528254600160a060020a03908116835260018401541660208301526002830154908201526003909101546060820152610
c18
565b610c
f0
576000610
d3f
565b610
d3f
83608060405190810160409081528254600160a060020a03908116835260018
085
0154
9091
1660208
4
015260028
4
01549
1830191909
1526003909
2
01546060820152
9089908901610c6b
565b5b9150600260008
9
51600160a060020a03168152602081019190915260400160009081205491508282011215610
d71
57fe5b610
d7d
84838301610
81c
565b94505b5
b5
05050509
3925
0505
05
65b600080600080600080610
da
187
886001610c6b
565b9350866040015184811515610d
b
257fe5b049250866040015183029150610d
c
787610e
c
5565b905081600260008951600160a060020a0316600160a060020a031681526020019081526020016000206000828254039250508190555081600260008960200151600160a060020a031681526020810191909152604001600020805490910190558260608801818151019052504260608801511115610
e4
157fe5b80821115610
e4
b57fe5b81828203955095505b50505050915091565b600160a060020a0381166000908152600360205260409020546005805482908110610
e8
457fe5b906000526020600020906004020160005b508054600160a060020a0319908116825560018201805490911690556000600282018190556003909101555b5050565b60008160400151826060015142030290505b919050565b
60008151600160a060020a03168351600160a060020a031614801561082d57508160200151600160a060020a03168360200151600160a060020a0316145b90505b92915050565b
8154818355818115116105f3576004028160040283600052602060002091820191016105f39190610
f7a
565b5b505050565b5080546000825560040290600052602060002090810190610
f76
9190610
f7a
565b5b50565b61046b91905b80821115610
fb9
578054600160a060020a0319908116825560018201805490911690556000600282018190556003820155600401610
f80
565b5090565b905600a165627a7a72305820
c51cb66e2d5a2a7215690fe6faed582be0203adebe118b7319e3572f86458766
0029
"
,
"
networks
"
:
{
"
networks
"
:
{
"
1500075197859
"
:
{
"
1500075197859
"
:
{
"
events
"
:
{
"
events
"
:
{
...
@@ -982,10 +982,10 @@ const contract = {
...
@@ -982,10 +982,10 @@ const contract = {
}
}
},
},
"
links
"
:
{},
"
links
"
:
{},
"
address
"
:
"
0x
c5dc2ba3aee4b8c2cdc659a27118a5c5317705dd
"
,
"
address
"
:
"
0x
aa6857c10e5d6acc37e2e7b0efc2749dfb213077
"
,
"
updated_at
"
:
15021
19211001
"
updated_at
"
:
15021
27244263
}
}
},
},
"
schema_version
"
:
"
0.0.5
"
,
"
schema_version
"
:
"
0.0.5
"
,
"
updated_at
"
:
15021
19211001
"
updated_at
"
:
15021
27244263
}
}
\ No newline at end of file
frontend/js/test.js
View file @
0866c0a4
...
@@ -213,6 +213,22 @@ function test3() {
...
@@ -213,6 +213,22 @@ function test3() {
streem
.
openStream
(
web3
.
eth
.
accounts
[
0
],
1
,
{
from
:
web3
.
eth
.
accounts
[
1
],
gas
:
200000
})
streem
.
openStream
(
web3
.
eth
.
accounts
[
0
],
1
,
{
from
:
web3
.
eth
.
accounts
[
1
],
gas
:
200000
})
}
}
function
test3a
()
{
console
.
log
(
'
open stream1: speed 1 from addr0 to addr1
'
)
streem
.
openStream
(
web3
.
eth
.
accounts
[
1
],
1
,
{
from
:
web3
.
eth
.
accounts
[
0
],
gas
:
200000
})
console
.
log
(
'
open stream2: speed 2 from addr1 to addr0
'
)
streem
.
openStream
(
web3
.
eth
.
accounts
[
0
],
2
,
{
from
:
web3
.
eth
.
accounts
[
1
],
gas
:
200000
})
}
function
test3b
()
{
console
.
log
(
'
open stream1: speed 2 from addr0 to addr1
'
)
streem
.
openStream
(
web3
.
eth
.
accounts
[
1
],
2
,
{
from
:
web3
.
eth
.
accounts
[
0
],
gas
:
200000
})
console
.
log
(
'
open stream2: speed 1 from addr1 to addr0
'
)
streem
.
openStream
(
web3
.
eth
.
accounts
[
0
],
1
,
{
from
:
web3
.
eth
.
accounts
[
1
],
gas
:
200000
})
}
function
test4
()
{
function
test4
()
{
console
.
log
(
'
open stream1: speed 1 from addr0 to addr1
'
)
console
.
log
(
'
open stream1: speed 1 from addr0 to addr1
'
)
streem
.
openStream
(
web3
.
eth
.
accounts
[
1
],
1
,
{
from
:
web3
.
eth
.
accounts
[
0
],
gas
:
200000
})
streem
.
openStream
(
web3
.
eth
.
accounts
[
1
],
1
,
{
from
:
web3
.
eth
.
accounts
[
0
],
gas
:
200000
})
...
...
frontend/test.html
View file @
0866c0a4
...
@@ -39,6 +39,8 @@ Size of streams array: <span id="nrstreams">-</span><br>
...
@@ -39,6 +39,8 @@ Size of streams array: <span id="nrstreams">-</span><br>
<button
id=
"test1a"
>
Test1a: close A->B, wait 20, close B->C
</button><br>
<button
id=
"test1a"
>
Test1a: close A->B, wait 20, close B->C
</button><br>
<button
id=
"test2"
>
Test2: open A->B (1), open B->C (2)
</button><br>
<button
id=
"test2"
>
Test2: open A->B (1), open B->C (2)
</button><br>
<button
id=
"test3"
>
Test3: open A->B (1), open B->A (1)
</button><br>
<button
id=
"test3"
>
Test3: open A->B (1), open B->A (1)
</button><br>
<button
id=
"test3a"
>
Test3a: open A->B (1), open B->A (2)
</button><br>
<button
id=
"test3b"
>
Test3b: open A->B (2), open B->A (1)
</button><br>
<button
id=
"test4"
>
Test4: open A->B (1), open B->C (1), open C->A (1)
</button><br>
<button
id=
"test4"
>
Test4: open A->B (1), open B->C (1), open C->A (1)
</button><br>
<script
type=
"text/javascript"
src=
"lib/web3.js"
></script>
<script
type=
"text/javascript"
src=
"lib/web3.js"
></script>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment