-
Notifications
You must be signed in to change notification settings - Fork 3
/
utxo_set.go
33 lines (27 loc) · 807 Bytes
/
utxo_set.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
package core
import (
"github.com/icstglobal/plasma/core/rawdb"
"github.com/icstglobal/plasma/core/types"
"github.com/icstglobal/plasma/store"
)
// UTXOSet is a utxo manager, which implements interface UtxoReaderWriter
type UTXOSet struct {
db store.Database
}
//NewUTXOSet connects utxoset to db
func NewUTXOSet(db store.Database) *UTXOSet {
return &UTXOSet{db: db}
}
//Get finds a utxo by id
//nil, if not found
func (us *UTXOSet) Get(id types.UTXOID) *types.UTXO {
return rawdb.ReadUTXO(us.db, id.BlockNum, id.TxIndex, id.OutIndex)
}
//Del remove a utxo from db
func (us *UTXOSet) Del(id types.UTXOID) error {
return rawdb.DeleteUTXO(us.db, id.BlockNum, id.TxIndex, id.OutIndex)
}
//Put saves a utxo into db
func (us *UTXOSet) Put(v *types.UTXO) error {
return rawdb.WriteUTXO(us.db, v)
}