Package net.plan99.payfile

Examples of net.plan99.payfile.Payfile$Data


    private void handlePayment(ByteString payment) throws ProtocolException {
        try {
            Protos.TwoWayChannelMessage paymentMessage = Protos.TwoWayChannelMessage.parseFrom(payment);
            paymentChannelClient.receiveMessage(paymentMessage);
        } catch (InvalidProtocolBufferException e) {
            throw new ProtocolException("Could not parse payment message: " + e.getMessage());
        } catch (InsufficientMoneyException e) {
            // This shouldn't happen as we shouldn't try to open a channel larger than what we can afford.
            throw new RuntimeException(e);
        }
    }
View Full Code Here


    }

    private void handleData(Payfile.Data data) throws IOException, ProtocolException {
        File file = handleToFile(data.getHandle());
        if (file == null)
            throw new ProtocolException("Unknown handle");
        if (data.getChunkId() == file.nextChunk - 1) {
            final byte[] bits = data.getData().toByteArray();
            file.bytesDownloaded += bits.length;
            file.downloadStream.write(bits);
            if ((data.getChunkId() + 1) * chunkSize >= file.getSize()) {
                // File is done.
                file.downloadStream.close();
                currentDownloads.remove(file);
                file.completionFuture.complete(null);
                currentFuture = null;
            } else {
                downloadNextChunk(file);
            }
        } else {
            throw new ProtocolException("Server sent wrong part of file");
        }
    }
View Full Code Here

        }
    }

    private void handleManifest(Payfile.Manifest manifest) throws ProtocolException {
        if (currentQuery == null)
            throw new ProtocolException("Got MANIFEST before QUERY_FILES");
        List<File> files = new ArrayList<>(manifest.getFilesCount());
        for (Payfile.File f : manifest.getFilesList()) {
            File file = new File(f.getFileName(), f.getDescription(), f.getHandle(), f.getSize(), f.getPricePerChunk());
            files.add(file);
        }
View Full Code Here

            try {
                running = true;
                while (true) {
                    int len = input.readInt();
                    if (len < 0 || len > 1024*1024)
                        throw new ProtocolException("Server sent message that's too large: " + len);
                    byte[] bits = new byte[len];
                    input.readFully(bits);
                    Payfile.PayFileMessage msg = Payfile.PayFileMessage.parseFrom(bits);
                    handle(msg);
                }
View Full Code Here

        return CompletableFuture.supplyAsync(() ->
            evalUnchecked(() -> {
                final InetSocketAddress address = new InetSocketAddress(server.getHostText(), server.getPort());
                final Socket socket = new Socket();
                socket.connect(address, timeoutMsec);
                return new PayFileClient(socket, bitcoin.wallet());
            })
        );
    }
View Full Code Here

    private Wallet.SendResult sendResult;

    // Called by FXMLLoader
    public void initialize() {
        new BitcoinAddressValidator(Main.params, address, sendBtn);
    }
View Full Code Here

        this.params = params;
        this.nodes = nodes;

        // Handle the red highlighting, but don't highlight in red just when the field is empty because that makes
        // the example/prompt address hard to read.
        new TextFieldValidator(field, text -> text.isEmpty() || testAddr(text));
        // However we do want the buttons to be disabled when empty so we apply a different test there.
        field.textProperty().addListener((observableValue, prev, current) -> {
            toggleButtons(current);
        });
        toggleButtons(field.getText());
View Full Code Here

        this.params = params;
        this.nodes = nodes;

        // Handle the red highlighting, but don't highlight in red just when the field is empty because that makes
        // the example/prompt address hard to read.
        new TextFieldValidator(field, text -> text.isEmpty() || testAddr(text));
        // However we do want the buttons to be disabled when empty so we apply a different test there.
        field.textProperty().addListener((observableValue, prev, current) -> {
            toggleButtons(current);
        });
        toggleButtons(field.getText());
View Full Code Here

    public ProgressOutputStream(OutputStream sink, long bytesSoFar, long expectedSize) {
        super(sink);
        this.bytesSoFar = new AtomicLong(bytesSoFar);
        this.progress = new SimpleDoubleProperty();
        this.throttler = new ThrottledRunLater(() -> progress.set(this.bytesSoFar.get() / (double) expectedSize));
    }
View Full Code Here

      Configuration configuration = project.getConfiguration();

      if (configuration != null)
      {
        Data data = configuration.getData();

        if (data != null)
        {
          ModuleDependencies moduleDependencies = data.getModuleDependencies();

          if (moduleDependencies != null)
          {
            dependencies = moduleDependencies.getDependency();
          }
View Full Code Here

TOP

Related Classes of net.plan99.payfile.Payfile$Data

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.