/
storage.go
47 lines (33 loc) · 1.33 KB
/
storage.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
package storage
import (
"math/big"
"github.com/KalyCoinProject/kalychain/types"
"github.com/hashicorp/go-hclog"
)
// Storage is a generic blockchain storage
type Storage interface {
ReadCanonicalHash(n uint64) (types.Hash, bool)
WriteCanonicalHash(n uint64, hash types.Hash) error
ReadHeadHash() (types.Hash, bool)
ReadHeadNumber() (uint64, bool)
WriteHeadHash(h types.Hash) error
WriteHeadNumber(uint64) error
WriteForks(forks []types.Hash) error
ReadForks() ([]types.Hash, error)
WriteTotalDifficulty(hash types.Hash, diff *big.Int) error
ReadTotalDifficulty(hash types.Hash) (*big.Int, bool)
WriteHeader(h *types.Header) error
ReadHeader(hash types.Hash) (*types.Header, error)
WriteCanonicalHeader(h *types.Header, diff *big.Int) error
WriteBody(hash types.Hash, body *types.Body) error
ReadBody(hash types.Hash) (*types.Body, error)
WriteSnapshot(hash types.Hash, blob []byte) error
ReadSnapshot(hash types.Hash) ([]byte, bool)
WriteReceipts(hash types.Hash, receipts []*types.Receipt) error
ReadReceipts(hash types.Hash) ([]*types.Receipt, error)
WriteTxLookup(hash types.Hash, blockHash types.Hash) error
ReadTxLookup(hash types.Hash) (types.Hash, bool)
Close() error
}
// Factory is a factory method to create a blockchain storage
type Factory func(config map[string]interface{}, logger hclog.Logger) (Storage, error)