-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlocks.java
More file actions
65 lines (56 loc) · 1.46 KB
/
Blocks.java
File metadata and controls
65 lines (56 loc) · 1.46 KB
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
package storage;
import java.util.ArrayList;
import model.lightchain.Block;
import model.lightchain.Identifier;
/**
* Persistent module for storing blocks on the disk.
*/
public interface Blocks {
/**
* Checks existence of block on the database.
*
* @param blockId Identifier of block.
* @return true if a block with that identifier exists, false otherwise.
*/
boolean has(Identifier blockId);
/**
* Adds block to the database.
*
* @param block given block to be added.
* @return true if block did not exist on the database, false if block is already in
* database.
*/
boolean add(Block block);
/**
* Removes block with given identifier.
*
* @param blockId identifier of the block.
* @return true if block exists on database and removed successfully, false if block does not exist on
* database.
*/
boolean remove(Identifier blockId);
/**
* Returns the block with given identifier.
*
* @param blockId identifier of the block.
* @return the block itself if exists and null otherwise.
*/
Block byId(Identifier blockId);
/**
* Returns the block with the given height.
*
* @param height height of the block.
* @return the block itself if exists and null otherwise.
*/
Block atHeight(long height);
/**
* Returns all blocks stored in database.
*
* @return all stored blocks in database.
*/
ArrayList<Block> all();
/**
* Closes the database.
*/
void close();
}