forked from rustyrussell/pettycoin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_block.h
75 lines (63 loc) · 2.41 KB
/
check_block.h
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
73
74
75
#ifndef PETTYCOIN_CHECK_BLOCK_H
#define PETTYCOIN_CHECK_BLOCK_H
#include "config.h"
#include "block_shard.h"
#include "protocol_net.h"
#include <ccan/short_types/short_types.h>
#include <stdbool.h>
#include <stddef.h>
struct protocol_block_header;
struct protocol_block_tailer;
struct protocol_double_sha;
struct protocol_proof;
struct state;
struct block;
struct log;
struct protocol_block_header *unmarshal_block_header(void *buffer, size_t size);
/* Returns error if bad. You should also call check_block_prev_txhashes! */
enum protocol_ecode
check_block_header(struct state *state,
const struct block_info *bi,
struct block **prev,
struct protocol_double_sha *sha);
/* Does merkle match? */
bool shard_belongs_in_block(const struct block *block,
const struct block_shard *shard);
/* If we put tx in shard at txoff, will it be in order? If not, give
* offset of conflicting tx in bad_txoff */
bool check_tx_ordering(struct state *state,
struct block *block,
struct block_shard *shard, u8 txoff,
const union protocol_tx *tx,
u8 *bad_txoff);
/* You normally call check_tx_ordering first! */
void put_tx_in_shard(struct state *state,
const struct peer *source,
struct block *block,
struct block_shard *shard, u8 txoff,
const struct txptr_with_ref txp);
bool put_txhash_in_shard(struct state *state,
struct block *block, u16 shardnum, u8 txoff,
const struct protocol_txrefhash *txrefhash);
/* After you've put in tx, you put in proof. */
void put_proof_in_shard(struct state *state,
struct block *block,
const struct protocol_proof *proof);
bool check_num_prev_txhashes(struct state *state,
const struct block *prev_block,
const struct protocol_block_header *hdr,
const u8 *prev_txhashes);
/* Check what we can, using block->prev etc's shards. */
bool check_prev_txhashes(struct state *state, const struct block *block,
const struct block **bad_prev,
u16 *bad_shard);
/* Check both inputs and references for this transaction. */
bool check_tx_inputs_and_refs(struct state *state,
struct block *block,
const struct protocol_proof *proof,
union protocol_tx *tx,
struct protocol_input_ref *refs,
const struct txhash_elem *me);
/* Various assertions about a block */
void check_block(struct state *state, const struct block *block, bool all);
#endif /* PETTYCOIN_CHECK_BLOCK_H */