forked from 0xs34n/blockchain
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessages.js
More file actions
39 lines (34 loc) · 658 Bytes
/
Messages.js
File metadata and controls
39 lines (34 loc) · 658 Bytes
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
const messageType = require("./message-type.js");
const {
REQUEST_LATEST_BLOCK,
RECEIVE_LATEST_BLOCK,
REQUEST_BLOCKCHAIN,
RECEIVE_BLOCKCHAIN,
REQUEST_TRANSACTIONS,
RECEIVE_TRANSACTIONS
} = messageType;
class Messages {
static getLatestBlock() {
return {
type: REQUEST_LATEST_BLOCK
};
}
static sendLatestBlock(block) {
return {
type: RECEIVE_LATEST_BLOCK,
data: block
};
}
static getBlockchain() {
return {
type: REQUEST_BLOCKCHAIN
};
}
static sendBlockchain(blockchain) {
return {
type: RECEIVE_BLOCKCHAIN,
data: blockchain
};
}
}
module.exports = Messages;