forked from hemilabs/heminetwork
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.go
More file actions
56 lines (42 loc) · 1.05 KB
/
Copy pathdatabase.go
File metadata and controls
56 lines (42 loc) · 1.05 KB
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) 2024-2025 Hemi Labs, Inc.
// Use of this source code is governed by the MIT License,
// which can be found in the LICENSE file.
package database
import (
"fmt"
"github.com/btcsuite/btcd/chaincfg/chainhash"
)
type Database interface {
Close() error // Close database
}
type NotFoundError string
func (nfe NotFoundError) Error() string {
return string(nfe)
}
func (nfe NotFoundError) Is(target error) bool {
_, ok := target.(NotFoundError)
return ok
}
type BlockNotFoundError struct {
chainhash.Hash
}
func (bnfe BlockNotFoundError) Error() string {
return fmt.Sprintf("block not found: %v", bnfe.Hash)
}
func (bnfe BlockNotFoundError) Is(target error) bool {
_, ok := target.(BlockNotFoundError)
return ok
}
type DuplicateError string
func (de DuplicateError) Error() string {
return string(de)
}
func (de DuplicateError) Is(target error) bool {
_, ok := target.(DuplicateError)
return ok
}
var (
ErrDuplicate = DuplicateError("duplicate")
ErrNotFound = NotFoundError("not found")
ErrBlockNotFound BlockNotFoundError
)