-
Notifications
You must be signed in to change notification settings - Fork 48
/
interface.go
76 lines (59 loc) · 2.18 KB
/
interface.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT License was not distributed with this
// file, you can obtain one at https://opensource.org/licenses/MIT.
//
// Copyright (c) DUSK NETWORK. All rights reserved.
package mempool
import (
"errors"
"time"
"github.com/dusk-network/dusk-blockchain/pkg/core/data/ipc/transactions"
)
var errNotFound = errors.New("not found")
type txHash [32]byte
// TxDesc encapsulates both tx raw and meta data.
type TxDesc struct {
tx transactions.ContractCall
// the point in time, tx was received in pending queue.
received time.Time
// the point in time, tx was moved into verified pool.
verified time.Time
size uint
// Kadcast transport-specific field.
kadHeight byte
}
// Pool represents a transaction pool of the verified txs only.
type Pool interface {
// Create instantiates the underlying data storage.
Create(path string) error
// Put sets the value for the given key. It overwrites any previous value
// for that key.
Put(t TxDesc) error
// Get retrieves a transaction for a given txID, if it exists.
Get(txID []byte) transactions.ContractCall
// GetTxsByNullifier returns a set of hashes of all transactions that
// contain a given nullifier.
GetTxsByNullifier(nullifier []byte) ([][]byte, error)
// ContainAnyNullifiers returns true if any pool transaction contains any of
// the given nullifiers.
ContainAnyNullifiers(nullifiers [][]byte) (bool, []byte)
// Contain returns true if the given key is in the pool.
Contain(key []byte) bool
// Delete a key in the pool.
Delete(key []byte) error
// Clone the entire pool.
Clone() []transactions.ContractCall
// FilterByType returns all verified transactions for a specific type.
FilterByType(transactions.TxType) []transactions.ContractCall
// Size is total number of bytes of all txs marshaling size.
Size() uint32
// Len returns the number of tx entries.
Len() int
// Range iterates through all tx entries.
Range(fn func(k txHash, t TxDesc) error) error
// RangeSort iterates through all tx entries sorted by Fee
// in a descending order.
RangeSort(fn func(k txHash, t TxDesc) (bool, error)) error
// Close closes backend.
Close()
}