Search in sources :

Example 1 with RpcResponseClosure

use of com.jd.blockchain.consensus.raft.rpc.RpcResponseClosure in project jdchain-core by blockchain-jd-com.

the class BlockClosure method run.

@Override
public void run(Status status) {
    int i = 0;
    for (Closure closure : this.getDoneList()) {
        int index = i;
        RpcResponseClosure submitTxDone = (RpcResponseClosure) closure;
        if (submitTxDone != null) {
            Utils.runClosureInThread(s -> {
                if (status.isOk()) {
                    AsyncFuture<byte[]> future = getFuture(index);
                    submitTxDone.setResponse(RpcResponse.success(future.get()));
                } else {
                    submitTxDone.setResponse(RpcResponse.fail(status.getCode(), status.getErrorMsg()));
                }
                submitTxDone.run(s);
            });
        }
        i++;
    }
}
Also used : RpcResponseClosure(com.jd.blockchain.consensus.raft.rpc.RpcResponseClosure) Closure(com.alipay.sofa.jraft.Closure) RpcResponseClosure(com.jd.blockchain.consensus.raft.rpc.RpcResponseClosure)

Aggregations

Closure (com.alipay.sofa.jraft.Closure)1 RpcResponseClosure (com.jd.blockchain.consensus.raft.rpc.RpcResponseClosure)1