-
Notifications
You must be signed in to change notification settings - Fork 0
/
Miner.java
72 lines (57 loc) · 1.87 KB
/
Miner.java
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
61
62
63
64
65
66
67
68
69
70
71
72
package edu.nyu.crypto.csci3033.miners;
import edu.nyu.crypto.csci3033.blockchain.Block;
import edu.nyu.crypto.csci3033.blockchain.NetworkStatistics;
public interface Miner {
/**
* @return the Block that the miner is currently extending. May not yet have been published.
*/
Block currentlyMiningAt();
/**
* Use this to announce new blocks (or not)
*
* @return The block that the miner views as the current head of the chain. Could be an old block or a newly announced block or the head of a chain of newly announced blocks.
*/
Block currentHead();
/**
* This method is used to inform the miner of new block.
* It is possible to hear of the same block multiple times.
* If the block was mined by this miner, the second parameter will be set to true.
* @param block block A block that has recently been announced
* @param isMinerMe boolean value indicating if the block was mined by this miner.
*/
void blockMined(Block block, boolean isMinerMe);
/**
* A change in the network may have happened.
* @param statistics The updated NetworkStatistics
*/
void networkUpdate(NetworkStatistics statistics);
/**
* @param genesis The genesis block
* @param statistics The original NetworkStatistics
*/
void initialize(Block genesis, NetworkStatistics statistics);
/**
* Hash Rate
*
* @return the number of hashes per second
*/
int getHashRate();
/**
*
* @param hashRate sets the hash rate of the Miner
*/
void setHashRate(int hashRate);
/**
* @return the inverse of the average ping time
*/
int getConnectivity();
/**
* Sets the connectivity of the Miner
* @param connectivity
*/
void setConnectivity(int connectivity);
/**
* @return The miners Id
*/
String getId();
}