forked from XRPLF/rippled
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathevents.h
155 lines (129 loc) · 3.75 KB
/
events.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012-2017 Ripple Labs Inc
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef RIPPLE_TEST_CSF_EVENTS_H_INCLUDED
#define RIPPLE_TEST_CSF_EVENTS_H_INCLUDED
#include <test/csf/Tx.h>
#include <test/csf/Validation.h>
#include <test/csf/ledgers.h>
#include <test/csf/Proposal.h>
#include <chrono>
namespace ripple {
namespace test {
namespace csf {
// Events are emitted by peers at a variety of points during the simulation.
// Each event is emitted by a particlar peer at a particular time. Collectors
// process these events, perhaps calculating statistics or storing events to
// a log for post-processing.
//
// The Event types can be arbitrary, but should be copyable and lightweight.
//
// Example collectors can be found in collectors.h, but have the general
// interface:
//
// @code
// template <class T>
// struct Collector
// {
// template <class Event>
// void
// on(peerID who, SimTime when, Event e);
// };
// @endcode
//
// CollectorRef.f defines a type-erased holder for arbitrary Collectors. If
// any new events are added, the interface there needs to be updated.
/** A value to be flooded to all other peers starting from this peer.
*/
template <class V>
struct Share
{
//! Event that is shared
V val;
};
/** A value relayed to another peer as part of flooding
*/
template <class V>
struct Relay
{
//! Peer relaying to
PeerID to;
//! The value to relay
V val;
};
/** A value received from another peer as part of flooding
*/
template <class V>
struct Receive
{
//! Peer that sent the value
PeerID from;
//! The received value
V val;
};
/** A transaction submitted to a peer */
struct SubmitTx
{
//! The submitted transaction
Tx tx;
};
/** Peer starts a new consensus round
*/
struct StartRound
{
//! The preferred ledger for the start of consensus
Ledger::ID bestLedger;
//! The prior ledger on hand
Ledger prevLedger;
};
/** Peer closed the open ledger
*/
struct CloseLedger
{
// The ledger closed on
Ledger prevLedger;
// Initial txs for including in ledger
TxSetType txs;
};
//! Peer accepted consensus results
struct AcceptLedger
{
// The newly created ledger
Ledger ledger;
// The prior ledger (this is a jump if prior.id() != ledger.parentID())
Ledger prior;
};
//! Peer detected a wrong prior ledger during consensus
struct WrongPrevLedger
{
// ID of wrong ledger we had
Ledger::ID wrong;
// ID of what we think is the correct ledger
Ledger::ID right;
};
//! Peer fully validated a new ledger
struct FullyValidateLedger
{
//! The new fully validated ledger
Ledger ledger;
//! The prior fully validated ledger
//! This is a jump if prior.id() != ledger.parentID()
Ledger prior;
};
} // namespace csf
} // namespace test
} // namespace ripple
#endif