-
Notifications
You must be signed in to change notification settings - Fork 0
/
orderer.go
48 lines (39 loc) · 1.29 KB
/
orderer.go
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
package abft
import (
"github.com/Deepchain-foundation/lachesis-base/abft/dagidx"
"github.com/Deepchain-foundation/lachesis-base/abft/election"
"github.com/Deepchain-foundation/lachesis-base/hash"
"github.com/Deepchain-foundation/lachesis-base/inter/idx"
"github.com/Deepchain-foundation/lachesis-base/inter/pos"
)
type OrdererCallbacks struct {
ApplyAtropos func(decidedFrame idx.Frame, atropos hash.Event) (sealEpoch *pos.Validators)
EpochDBLoaded func(idx.Epoch)
}
type OrdererDagIndex interface {
dagidx.ForklessCause
}
// Orderer processes events to reach finality on their order.
// Unlike abft.Lachesis, this raw level of abstraction doesn't track cheaters detection
type Orderer struct {
config Config
crit func(error)
store *Store
input EventSource
election *election.Election
dagIndex OrdererDagIndex
callback OrdererCallbacks
}
// NewOrderer creates Orderer instance.
// Unlike Lachesis, Orderer doesn't updates DAG indexes for events, and doesn't detect cheaters
// It has only one purpose - reaching consensus on events order.
func NewOrderer(store *Store, input EventSource, dagIndex OrdererDagIndex, crit func(error), config Config) *Orderer {
p := &Orderer{
config: config,
store: store,
input: input,
crit: crit,
dagIndex: dagIndex,
}
return p
}