|
@ -2,6 +2,7 @@ package consensus |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
"bytes" |
|
|
"bytes" |
|
|
|
|
|
"encoding/json" |
|
|
"fmt" |
|
|
"fmt" |
|
|
"hash/crc32" |
|
|
"hash/crc32" |
|
|
"io" |
|
|
"io" |
|
@ -190,13 +191,23 @@ type Handshaker struct { |
|
|
stateDB dbm.DB |
|
|
stateDB dbm.DB |
|
|
initialState sm.State |
|
|
initialState sm.State |
|
|
store types.BlockStore |
|
|
store types.BlockStore |
|
|
|
|
|
appState json.RawMessage |
|
|
logger log.Logger |
|
|
logger log.Logger |
|
|
|
|
|
|
|
|
nBlocks int // number of blocks applied to the state
|
|
|
nBlocks int // number of blocks applied to the state
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func NewHandshaker(stateDB dbm.DB, state sm.State, store types.BlockStore) *Handshaker { |
|
|
|
|
|
return &Handshaker{stateDB, state, store, log.NewNopLogger(), 0} |
|
|
|
|
|
|
|
|
func NewHandshaker(stateDB dbm.DB, state sm.State, |
|
|
|
|
|
store types.BlockStore, appState json.RawMessage) *Handshaker { |
|
|
|
|
|
|
|
|
|
|
|
return &Handshaker{ |
|
|
|
|
|
stateDB: stateDB, |
|
|
|
|
|
initialState: state, |
|
|
|
|
|
store: store, |
|
|
|
|
|
appState: appState, |
|
|
|
|
|
logger: log.NewNopLogger(), |
|
|
|
|
|
nBlocks: 0, |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (h *Handshaker) SetLogger(l log.Logger) { |
|
|
func (h *Handshaker) SetLogger(l log.Logger) { |
|
@ -249,9 +260,12 @@ func (h *Handshaker) ReplayBlocks(state sm.State, appHash []byte, appBlockHeight |
|
|
// If appBlockHeight == 0 it means that we are at genesis and hence should send InitChain
|
|
|
// If appBlockHeight == 0 it means that we are at genesis and hence should send InitChain
|
|
|
if appBlockHeight == 0 { |
|
|
if appBlockHeight == 0 { |
|
|
validators := types.TM2PB.Validators(state.Validators) |
|
|
validators := types.TM2PB.Validators(state.Validators) |
|
|
// TODO: get the genesis bytes (https://github.com/tendermint/tendermint/issues/1224)
|
|
|
|
|
|
var genesisBytes []byte |
|
|
|
|
|
if _, err := proxyApp.Consensus().InitChainSync(abci.RequestInitChain{validators, genesisBytes}); err != nil { |
|
|
|
|
|
|
|
|
req := abci.RequestInitChain{ |
|
|
|
|
|
Validators: validators, |
|
|
|
|
|
AppStateBytes: h.appState, |
|
|
|
|
|
} |
|
|
|
|
|
_, err := proxyApp.Consensus().InitChainSync(req) |
|
|
|
|
|
if err != nil { |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|