@@ -22,8 +22,8 @@ import (
22
22
23
23
"github.com/ethereum/go-ethereum/common"
24
24
"github.com/ethereum/go-ethereum/consensus"
25
- "github.com/ethereum/go-ethereum/consensus/pbft "
26
- pbftCore "github.com/ethereum/go-ethereum/consensus/pbft /core"
25
+ "github.com/ethereum/go-ethereum/consensus/istanbul "
26
+ istanbulCore "github.com/ethereum/go-ethereum/consensus/istanbul /core"
27
27
"github.com/ethereum/go-ethereum/core"
28
28
"github.com/ethereum/go-ethereum/core/types"
29
29
"github.com/ethereum/go-ethereum/crypto"
@@ -32,53 +32,53 @@ import (
32
32
"github.com/ethereum/go-ethereum/log"
33
33
)
34
34
35
- // New creates an Ethereum backend for PBFT core engine.
36
- func New (config * pbft .Config , eventMux * event.TypeMux , privateKey * ecdsa.PrivateKey , db ethdb.Database ) consensus.PBFT {
35
+ // New creates an Ethereum backend for Istanbul core engine.
36
+ func New (config * istanbul .Config , eventMux * event.TypeMux , privateKey * ecdsa.PrivateKey , db ethdb.Database ) consensus.Istanbul {
37
37
backend := & simpleBackend {
38
- config : config ,
39
- peerSet : newPeerSet (),
40
- eventMux : eventMux ,
41
- pbftEventMux : new (event.TypeMux ),
42
- privateKey : privateKey ,
43
- address : crypto .PubkeyToAddress (privateKey .PublicKey ),
44
- logger : log .New ("backend" , "simple" ),
45
- db : db ,
46
- commitCh : make (chan common.Hash , 1 ),
38
+ config : config ,
39
+ peerSet : newPeerSet (),
40
+ eventMux : eventMux ,
41
+ istanbulEventMux : new (event.TypeMux ),
42
+ privateKey : privateKey ,
43
+ address : crypto .PubkeyToAddress (privateKey .PublicKey ),
44
+ logger : log .New ("backend" , "simple" ),
45
+ db : db ,
46
+ commitCh : make (chan common.Hash , 1 ),
47
47
}
48
48
return backend
49
49
}
50
50
51
51
// ----------------------------------------------------------------------------
52
52
53
53
type simpleBackend struct {
54
- config * pbft .Config
55
- peerSet * peerSet
56
- valSet pbft .ValidatorSet
57
- eventMux * event.TypeMux
58
- pbftEventMux * event.TypeMux
59
- privateKey * ecdsa.PrivateKey
60
- address common.Address
61
- core pbftCore .Engine
62
- logger log.Logger
63
- quitSync chan struct {}
64
- db ethdb.Database
65
- timeout uint64
66
- chain consensus.ChainReader
67
- inserter func (block * types.Block ) error
68
-
69
- // the channels for pbft engine notifications
54
+ config * istanbul .Config
55
+ peerSet * peerSet
56
+ valSet istanbul .ValidatorSet
57
+ eventMux * event.TypeMux
58
+ istanbulEventMux * event.TypeMux
59
+ privateKey * ecdsa.PrivateKey
60
+ address common.Address
61
+ core istanbulCore .Engine
62
+ logger log.Logger
63
+ quitSync chan struct {}
64
+ db ethdb.Database
65
+ timeout uint64
66
+ chain consensus.ChainReader
67
+ inserter func (block * types.Block ) error
68
+
69
+ // the channels for istanbul engine notifications
70
70
commitCh chan common.Hash
71
71
proposedBlockHash common.Hash
72
72
sealMu sync.Mutex
73
73
}
74
74
75
- // Address implements pbft .Backend.Address
75
+ // Address implements istanbul .Backend.Address
76
76
func (sb * simpleBackend ) Address () common.Address {
77
77
return sb .address
78
78
}
79
79
80
- // Validators implements pbft .Backend.Validators
81
- func (sb * simpleBackend ) Validators () pbft .ValidatorSet {
80
+ // Validators implements istanbul .Backend.Validators
81
+ func (sb * simpleBackend ) Validators () istanbul .ValidatorSet {
82
82
return sb .valSet
83
83
}
84
84
@@ -88,34 +88,34 @@ func (sb *simpleBackend) Send(payload []byte, target common.Address) error {
88
88
return errInvalidPeer
89
89
}
90
90
91
- go sb .eventMux .Post (pbft .ConsensusDataEvent {
91
+ go sb .eventMux .Post (istanbul .ConsensusDataEvent {
92
92
PeerID : peer .ID (),
93
93
Data : payload ,
94
94
})
95
95
return nil
96
96
}
97
97
98
- // Broadcast implements pbft .Backend.Send
98
+ // Broadcast implements istanbul .Backend.Send
99
99
func (sb * simpleBackend ) Broadcast (payload []byte ) error {
100
- pbftMsg := pbft .MessageEvent {
100
+ istanbulMsg := istanbul .MessageEvent {
101
101
Payload : payload ,
102
102
}
103
103
104
104
// send to self
105
- go sb .pbftEventMux .Post (pbftMsg )
105
+ go sb .istanbulEventMux .Post (istanbulMsg )
106
106
107
107
// send to other peers
108
108
for _ , peer := range sb .peerSet .List () {
109
- go sb .eventMux .Post (pbft .ConsensusDataEvent {
109
+ go sb .eventMux .Post (istanbul .ConsensusDataEvent {
110
110
PeerID : peer .ID (),
111
111
Data : payload ,
112
112
})
113
113
}
114
114
return nil
115
115
}
116
116
117
- // Commit implements pbft .Backend.Commit
118
- func (sb * simpleBackend ) Commit (proposal pbft .Proposal ) error {
117
+ // Commit implements istanbul .Backend.Commit
118
+ func (sb * simpleBackend ) Commit (proposal istanbul .Proposal ) error {
119
119
// Check if the proposal is a valid block
120
120
block := & types.Block {}
121
121
block , ok := proposal .(* types.Block )
@@ -148,13 +148,13 @@ func (sb *simpleBackend) NextRound() error {
148
148
return nil
149
149
}
150
150
151
- // EventMux implements pbft .Backend.EventMux
151
+ // EventMux implements istanbul .Backend.EventMux
152
152
func (sb * simpleBackend ) EventMux () * event.TypeMux {
153
- return sb .pbftEventMux
153
+ return sb .istanbulEventMux
154
154
}
155
155
156
- // Verify implements pbft .Backend.Verify
157
- func (sb * simpleBackend ) Verify (proposal pbft .Proposal ) error {
156
+ // Verify implements istanbul .Backend.Verify
157
+ func (sb * simpleBackend ) Verify (proposal istanbul .Proposal ) error {
158
158
// Check if the proposal is a valid block
159
159
block := & types.Block {}
160
160
block , ok := proposal .(* types.Block )
@@ -166,13 +166,13 @@ func (sb *simpleBackend) Verify(proposal pbft.Proposal) error {
166
166
return sb .VerifyHeader (sb .chain , block .Header (), false )
167
167
}
168
168
169
- // Sign implements pbft .Backend.Sign
169
+ // Sign implements istanbul .Backend.Sign
170
170
func (sb * simpleBackend ) Sign (data []byte ) ([]byte , error ) {
171
171
hashData := crypto .Keccak256 ([]byte (data ))
172
172
return crypto .Sign (hashData , sb .privateKey )
173
173
}
174
174
175
- // CheckSignature implements pbft .Backend.CheckSignature
175
+ // CheckSignature implements istanbul .Backend.CheckSignature
176
176
func (sb * simpleBackend ) CheckSignature (data []byte , address common.Address , sig []byte ) error {
177
177
signer , err := sb .getSignatureAddress (data , sig )
178
178
if err != nil {
@@ -186,7 +186,7 @@ func (sb *simpleBackend) CheckSignature(data []byte, address common.Address, sig
186
186
return nil
187
187
}
188
188
189
- // CheckValidatorSignature implements pbft .Backend.CheckValidatorSignature
189
+ // CheckValidatorSignature implements istanbul .Backend.CheckValidatorSignature
190
190
func (sb * simpleBackend ) CheckValidatorSignature (data []byte , sig []byte ) (common.Address , error ) {
191
191
// 1. Get signature address
192
192
signer , err := sb .getSignatureAddress (data , sig )
@@ -200,7 +200,7 @@ func (sb *simpleBackend) CheckValidatorSignature(data []byte, sig []byte) (commo
200
200
return val .Address (), nil
201
201
}
202
202
203
- return common.Address {}, pbft .ErrUnauthorizedAddress
203
+ return common.Address {}, istanbul .ErrUnauthorizedAddress
204
204
}
205
205
206
206
// get the signer address from the signature
0 commit comments