forked from rustyrussell/bitcoin-iterate
-
Notifications
You must be signed in to change notification settings - Fork 2
/
parse.h
78 lines (73 loc) · 2.16 KB
/
parse.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
76
77
78
/*******************************************************************************
*
* = parse.h
*
* Defines functions for parsing block headers & transactions from files
* on disk.
*
*/
#ifndef BITCOIN_PARSE_PARSE_H
#define BITCOIN_PARSE_PARSE_H
#include "types.h"
#include "io.h"
#include "space.h"
/**
* next_block_header_prefix - Fast-forward *off to head of next block,
* or false if not found.
*
* @f: current file
* @off: current file offset
* @marker: marker for block header
*
* This is the first step in iterating over the blockchain as it
* allows scanning to the beginning of the block you want to iterate
* from.
*/
bool next_block_header_prefix(struct file *f, off_t *off, const u32 marker);
/**
* read_block_header - Reads the block header from disk into
* *block.
*
* @bh: block header data structure to populate
* @f: current file
* @off: current file offset
* @block_md: hash for the block
* @marker: marker for block header
*
* This is the second step in iterating over the blockchain and it
* occurs again for each new block iterated over.
*/
bool read_block_header(struct block_header *bh,
struct file *f, off_t *off,
u8 block_md[SHA256_DIGEST_LENGTH],
const u32 marker);
/**
* skip_transactions - Fast-forward *off through past block
* *b's transactions.
*
* @bh: block header
* @block_start: block offset
* @off: current file offset
*
* This is the third step in iterating over the blockchain as it
* allows skipping all the transactions in a block and (therefore)
* jumping to the next block.
*/
void skip_transactions(const struct block_header *bh,
off_t block_start, off_t *off);
/**
* read_transaction - Reads a transaction from disk into *t.
*
* @space: space used for allocation
* @t: transaction data structure to populate
* @f: current file
* @off: current file offset
*
* This is the fourth step in iterating over the blockchain as, once
* the first block has been reached, this allows iterating over all
* subsequent transactions.
*/
void read_transaction(struct space *space,
struct transaction *t,
struct file *f, off_t *off);
#endif /* BITCOIN_PARSE_PARSE_H */