forked from ava-labs/avalanchego
-
Notifications
You must be signed in to change notification settings - Fork 4
/
tx.go
56 lines (47 loc) · 1.83 KB
/
tx.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
49
50
51
52
53
54
55
56
// Copyright (C) 2019-2022, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package snowstorm
import (
"github.com/MetalBlockchain/metalgo/ids"
"github.com/MetalBlockchain/metalgo/snow/choices"
)
// Whitelister defines the interface for specifying whitelisted operations.
type Whitelister interface {
// Returns [true] if the underlying instance does implement whitelisted
// conflicts.
HasWhitelist() bool
// Whitelist returns the set of transaction IDs that are explicitly
// whitelisted. Transactions that are not explicitly whitelisted are
// considered conflicting.
Whitelist() (ids.Set, error)
}
// Tx consumes state.
type Tx interface {
choices.Decidable
Whitelister
// Dependencies is a list of transactions upon which this transaction
// depends. Each element of Dependencies must be verified before Verify is
// called on this transaction.
//
// Similarly, each element of Dependencies must be accepted before this
// transaction is accepted.
Dependencies() ([]Tx, error)
// InputIDs is a set where each element is the ID of a piece of state that
// will be consumed if this transaction is accepted.
//
// In the context of a UTXO-based payments system, for example, this would
// be the IDs of the UTXOs consumed by this transaction
InputIDs() []ids.ID
// Verify that the state transition this transaction would make if it were
// accepted is valid. If the state transition is invalid, a non-nil error
// should be returned.
//
// It is guaranteed that when Verify is called, all the dependencies of
// this transaction have already been successfully verified.
Verify() error
// Bytes returns the binary representation of this transaction.
//
// This is used for sending transactions to peers. Another node should be
// able to parse these bytes to the same transaction.
Bytes() []byte
}