Search in sources :

Example 1 with RaftConsensusClient

use of com.jd.blockchain.consensus.raft.client.RaftConsensusClient in project jdchain-core by blockchain-jd-com.

the class GatewayConsensusClientManager method isCredentialUpated.

private boolean isCredentialUpated(ConsensusClient client, SessionCredential sessionCredential) {
    if (client instanceof BftsmartConsensusClient && sessionCredential instanceof BftsmartSessionCredential) {
        BftsmartConsensusClient bftsmartClient = (BftsmartConsensusClient) client;
        BftsmartSessionCredential newCredential = (BftsmartSessionCredential) sessionCredential;
        BftsmartSessionCredential oldCredential = bftsmartClient.getSettings().getSessionCredential();
        // clientId 和 clientIdRange 任何一个有差异,都表示凭证已更新;
        return oldCredential.getClientId() != newCredential.getClientId() || oldCredential.getClientIdRange() != newCredential.getClientIdRange();
    } else if (client instanceof RaftConsensusClient) {
        // return !((RaftConsensusClient)client).isInit();
        return !((RaftConsensusClient) client).isConnected();
    }
    return true;
}
Also used : RaftConsensusClient(com.jd.blockchain.consensus.raft.client.RaftConsensusClient) BftsmartConsensusClient(com.jd.blockchain.consensus.bftsmart.client.BftsmartConsensusClient) BftsmartSessionCredential(com.jd.blockchain.consensus.bftsmart.BftsmartSessionCredential)

Aggregations

BftsmartSessionCredential (com.jd.blockchain.consensus.bftsmart.BftsmartSessionCredential)1 BftsmartConsensusClient (com.jd.blockchain.consensus.bftsmart.client.BftsmartConsensusClient)1 RaftConsensusClient (com.jd.blockchain.consensus.raft.client.RaftConsensusClient)1