forked from ava-labs/avalanchego
-
Notifications
You must be signed in to change notification settings - Fork 4
/
decidable.go
46 lines (39 loc) · 1.39 KB
/
decidable.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
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package choices
import (
"context"
"github.com/MetalBlockchain/metalgo/ids"
)
// Decidable represents element that can be decided.
//
// Decidable objects are typically thought of as either transactions, blocks, or
// vertices.
type Decidable interface {
// ID returns a unique ID for this element.
//
// Typically, this is implemented by using a cryptographic hash of a
// binary representation of this element. An element should return the same
// IDs upon repeated calls.
ID() ids.ID
// Accept this element.
//
// This element will be accepted by every correct node in the network.
// All subsequent Status calls return Accepted.
Accept(context.Context) error
// Reject this element.
//
// This element will not be accepted by any correct node in the network.
// All subsequent Status calls return Rejected.
Reject(context.Context) error
// Status returns this element's current status.
//
// If Accept has been called on an element with this ID, Accepted should be
// returned. Similarly, if Reject has been called on an element with this
// ID, Rejected should be returned. If the contents of this element are
// unknown, then Unknown should be returned. Otherwise, Processing should be
// returned.
//
// TODO: Consider allowing Status to return an error.
Status() Status
}