All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.hyperchain.sdk.service.impl.ArchiveServiceImpl Maven / Gradle / Ivy

There is a newer version: 1.4.3
Show newest version
package cn.hyperchain.sdk.service.impl;

import cn.hyperchain.sdk.provider.ProviderManager;
import cn.hyperchain.sdk.request.ArchiveRequest;
import cn.hyperchain.sdk.request.Request;
import cn.hyperchain.sdk.response.archive.ArchiveBoolResponse;
import cn.hyperchain.sdk.response.archive.ArchiveFilterIdResponse;
import cn.hyperchain.sdk.response.archive.ArchiveResponse;
import cn.hyperchain.sdk.service.ArchiveService;

import java.math.BigInteger;

public class ArchiveServiceImpl implements ArchiveService {
    public static final String ARCHIVE_PRE = "archive_";
    public ProviderManager providerManager;

    public ArchiveServiceImpl(ProviderManager providerManager) {
        this.providerManager = providerManager;
    }

    @Override
    public Request snapshot(BigInteger blockNumber, int... nodeIds) {
        return snapshot(blockNumber.toString(), nodeIds);
    }

    @Override
    public Request snapshot(String blockNumber, int... nodeIds) {
        ArchiveRequest archiveRequest = new ArchiveRequest(ARCHIVE_PRE + "snapshot", providerManager, ArchiveFilterIdResponse.class, nodeIds);
        archiveRequest.addParams(blockNumber);

        return archiveRequest;
    }

    @Override
    public Request querySnapshotExist(String filterId, int... nodeIds) {
        ArchiveRequest archiveRequest = new ArchiveRequest(ARCHIVE_PRE + "querySnapshotExist", providerManager, ArchiveBoolResponse.class, nodeIds);
        archiveRequest.addParams(filterId);
        return archiveRequest;
    }

    @Override
    public Request checkSnapshot(String filterId, int... nodeIds) {
        ArchiveRequest archiveRequest = new ArchiveRequest(ARCHIVE_PRE + "checkSnapshot", providerManager, ArchiveBoolResponse.class, nodeIds);
        archiveRequest.addParams(filterId);
        return archiveRequest;
    }

    @Override
    public Request deleteSnapshot(String filterId, int... nodeIds) {
        ArchiveRequest archiveRequest = new ArchiveRequest(ARCHIVE_PRE + "deleteSnapshot", providerManager, ArchiveBoolResponse.class, nodeIds);
        archiveRequest.addParams(filterId);
        return archiveRequest;
    }

    @Override
    public Request listSnapshot(int... nodeIds) {
        ArchiveRequest archiveRequest = new ArchiveRequest(ARCHIVE_PRE + "listSnapshot", providerManager, ArchiveResponse.class, nodeIds);
        return archiveRequest;
    }

    @Override
    public Request readSnapshot(String filterId, int... nodeIds) {
        ArchiveRequest archiveRequest = new ArchiveRequest(ARCHIVE_PRE + "readSnapshot", providerManager, ArchiveResponse.class, nodeIds);
        archiveRequest.addParams(filterId);
        return archiveRequest;
    }

    @Override
    public Request archive(String filterId, boolean sync, int... nodeIds) {
        ArchiveRequest archiveRequest = new ArchiveRequest(ARCHIVE_PRE + "archive", providerManager, ArchiveBoolResponse.class, nodeIds);
        archiveRequest.addParams(filterId);
        archiveRequest.addParams(sync);
        return archiveRequest;
    }

    @Override
    public Request archiveNoPredict(BigInteger blkNumber, int... nodeIds) {
        ArchiveRequest archiveRequest = new ArchiveRequest(ARCHIVE_PRE + "archiveNoPredict", providerManager, ArchiveBoolResponse.class, nodeIds);
        archiveRequest.addParams(blkNumber);
        return archiveRequest;
    }

    @Override
    public Request restore(String filterId, boolean sync, int... nodeIds) {
        ArchiveRequest archiveRequest = new ArchiveRequest(ARCHIVE_PRE + "restore", providerManager, ArchiveBoolResponse.class, nodeIds);
        archiveRequest.addParams(filterId);
        archiveRequest.addParams(sync);
        return archiveRequest;
    }

    @Override
    public Request restoreAll(boolean sync, int... nodeIds) {
        ArchiveRequest archiveRequest = new ArchiveRequest(ARCHIVE_PRE + "restoreAll", providerManager, ArchiveBoolResponse.class, nodeIds);
        archiveRequest.addParams(sync);
        return archiveRequest;
    }

    @Override
    public Request queryArchive(String filterId, int... nodeIds) {
        ArchiveRequest archiveRequest = new ArchiveRequest(ARCHIVE_PRE + "queryArchive", providerManager, ArchiveBoolResponse.class, nodeIds);
        archiveRequest.addParams(filterId);
        return archiveRequest;
    }

    @Override
    public Request pending(int... nodeIds) {
        ArchiveRequest archiveRequest = new ArchiveRequest(ARCHIVE_PRE + "pending", providerManager, ArchiveResponse.class, nodeIds);
        return archiveRequest;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy