-
Notifications
You must be signed in to change notification settings - Fork 202
/
interface.go
113 lines (101 loc) · 2.9 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package data
import (
"math/big"
)
// HeaderHandler defines getters and setters for header data holder
type HeaderHandler interface {
GetShardID() uint32
GetNonce() uint64
GetEpoch() uint32
GetRound() uint64
GetRootHash() []byte
GetValidatorStatsRootHash() []byte
GetPrevHash() []byte
GetPrevRandSeed() []byte
GetRandSeed() []byte
GetPubKeysBitmap() []byte
GetSignature() []byte
GetLeaderSignature() []byte
GetTimeStamp() uint64
GetTxCount() uint32
SetNonce(n uint64)
SetEpoch(e uint32)
SetRound(r uint64)
SetTimeStamp(ts uint64)
SetRootHash(rHash []byte)
SetValidatorStatsRootHash(rHash []byte)
SetPrevHash(pvHash []byte)
SetPrevRandSeed(pvRandSeed []byte)
SetRandSeed(randSeed []byte)
SetPubKeysBitmap(pkbm []byte)
SetSignature(sg []byte)
SetLeaderSignature(sg []byte)
SetTxCount(txCount uint32)
GetMiniBlockHeadersWithDst(destId uint32) map[string]uint32
IsInterfaceNil() bool
ItemsInBody() uint32
ItemsInHeader() uint32
Clone() HeaderHandler
}
// BodyHandler interface for a block body
type BodyHandler interface {
// IntegrityAndValidity checks the integrity and validity of the block
IntegrityAndValidity() error
// IsInterfaceNil returns true if there is no value under the interface
IsInterfaceNil() bool
}
// ChainHandler is the interface defining the functionality a blockchain should implement
type ChainHandler interface {
GetGenesisHeader() HeaderHandler
SetGenesisHeader(gb HeaderHandler) error
GetGenesisHeaderHash() []byte
SetGenesisHeaderHash(hash []byte)
GetCurrentBlockHeader() HeaderHandler
SetCurrentBlockHeader(bh HeaderHandler) error
GetCurrentBlockHeaderHash() []byte
SetCurrentBlockHeaderHash(hash []byte)
GetCurrentBlockBody() BodyHandler
SetCurrentBlockBody(body BodyHandler) error
GetLocalHeight() int64
SetLocalHeight(height int64)
GetNetworkHeight() int64
SetNetworkHeight(height int64)
HasBadBlock(blockHash []byte) bool
PutBadBlock(blockHash []byte)
IsInterfaceNil() bool
}
// TransactionHandler defines the type of executable transaction
type TransactionHandler interface {
IsInterfaceNil() bool
GetValue() *big.Int
GetNonce() uint64
GetData() string
GetRecvAddress() []byte
GetSndAddress() []byte
GetGasLimit() uint64
GetGasPrice() uint64
SetValue(*big.Int)
SetData(string)
SetRecvAddress([]byte)
SetSndAddress([]byte)
}
//Trie is an interface for Merkle Trees implementations
type Trie interface {
Get(key []byte) ([]byte, error)
Update(key, value []byte) error
Delete(key []byte) error
Root() ([]byte, error)
Prove(key []byte) ([][]byte, error)
VerifyProof(proofs [][]byte, key []byte) (bool, error)
Commit() error
Recreate(root []byte) (Trie, error)
String() string
DeepClone() (Trie, error)
IsInterfaceNil() bool
}
// DBWriteCacher is used to cache changes made to the trie, and only write to the database when it's needed
type DBWriteCacher interface {
Put(key, val []byte) error
Get(key []byte) ([]byte, error)
IsInterfaceNil() bool
}