-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconstact.sol
66 lines (49 loc) · 1.28 KB
/
constact.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
pragma solidity ^0.4.21;
contract Node{
byte[500] public image;
Node next;
function Node(byte[] res){
setImage(res);
}
function getNext()public returns(Node){
return next;
}
function setNext(Node _next)public{
next = _next;
}
function getImage() public constant returns(byte[500] res){
return image;
}
function setImage(byte[] res) public{
for(uint c1=0;c1<res.length;c1++){
image[c1]=res[c1];
}
}
function attachToHead(address addr)public returns(bool){
bytes4 methodId = bytes4(keccak256("attach()"));
return addr.call(methodId);
}
}
contract manager{
// address master;
uint count;
Node public head;
function manager(byte[] img) public{
head = new Node(img);
// master = sender;
count = 0;
}
function getImage(uint index)public constant returns(byte[500] res){
Node temp = head;
index = count - index;
for(uint c1=0;c1<index;c1++)
temp = temp.getNext();
return temp.getImage();
}
function attach()public {
Node temp = Node(msg.sender);
temp.setNext(head);
head = temp;
count+=1;
}
}