Annotate the mnesia records with types.
[etorrent.git] / lib / etorrent-1.0 / include / etorrent_mnesia_table.hrl
blob04b1989201b49f78d18b31dc8b2d422f02b7163f
1 %% Sequences, as in SQL SEQUENCES
2 -record(sequence, {name :: atom(),
3 count :: non_neg_integer()}).
5 -type(tracking_map_state() :: 'started' | 'stopped' | 'checking' | 'awaiting' | 'duplicate').
7 %% The tracking map tracks torrent id's to filenames, etc. It is the high-level view
8 -record(tracking_map, {id :: integer(), %% Unique identifier of torrent
9 filename :: string(), %% The filename
10 supervisor_pid :: pid(), %% The Pid of who is supervising the torrent
11 info_hash :: binary() | 'unknown',
12 state :: tracking_map_state()}).
14 %% The path map tracks file system paths and maps them to integers.
15 -record(path_map, {id :: {non_neg_integer() | '_', non_neg_integer()},
16 path :: string() | '_'}). % (IDX) File system path minus work dir
18 -type(torrent_state() :: 'leeching' | 'seeding' | 'endgame' | 'unknown').
20 %% A single torrent is represented as the 'torrent' record
21 -record(torrent, {id :: non_neg_integer(), % Unique identifier of torrent, monotonically increasing
22 % foreign keys to tracking_map.id
23 left :: non_neg_integer(), % How many bytes are there left before we have the
24 % full torrent
25 total :: non_neg_integer(), % How many bytes are there in total
26 uploaded :: non_neg_integer(), % How many bytes have we uploaded
27 downloaded :: non_neg_integer(), % How many bytes have we downloaded
28 pieces = unknown :: non_neg_integer() | 'unknown', % Number of pieces this torrent has
29 seeders = 0 :: non_neg_integer(), % How many people have a completed file?
30 leechers = 0 :: non_neg_integer(), % How many people are downloaded
31 state :: torrent_state()}). % What is our state: leecher | unknown | seeder | endgame
33 %% Counter for how many pieces is missing from this torrent
34 -record(torrent_c_pieces, {id :: non_neg_integer(), % Torrent id
35 missing :: non_neg_integer()}). % Number of missing pieces
37 -record(peer, {pid :: pid(), % We identify each peer with it's pid.
38 ip, % Ip of peer in question
39 port :: non_neg_integer(), % Port of peer in question
40 torrent_id :: non_neg_integer()}). % (IDX) Torrent Id this peer belongs to
42 -type(diskstate_state() :: 'seeding' | {'bitfield', binary()}).
43 %% Piece state on disk for persistence
44 -record(piece_diskstate, {filename :: string(), % Name of torrent
45 state :: diskstate_state()}). % state | {bitfield, BF}