target stringlengths 20 113k | src_fm stringlengths 11 86.3k | src_fm_fc stringlengths 21 86.4k | src_fm_fc_co stringlengths 30 86.4k | src_fm_fc_ms stringlengths 31 126k | src_fm_fc_ms_ff stringlengths 32 126k |
|---|---|---|---|---|---|
@Test public void testTranspose() throws Exception { DistributedRowMatrix m = randomDistributedMatrix(10, 9, 5, 4, 1.0, false); DistributedRowMatrix mt = m.transpose(); Path tmpPath = getTestTempDirPath(); m.setOutputTempPathString(tmpPath.toString()); Path tmpOutPath = new Path(tmpPath, "/tmpOutTranspose"); mt.setOutp... | public DistributedRowMatrix transpose() throws IOException { Path outputPath = new Path(rowPath.getParent(), "transpose-" + (System.nanoTime() & 0xFF)); Configuration initialConf = getConf() == null ? new Configuration() : getConf(); Configuration conf = TransposeJob.buildTransposeJobConf(initialConf, rowPath, outputPa... | DistributedRowMatrix implements VectorIterable, Configurable { public DistributedRowMatrix transpose() throws IOException { Path outputPath = new Path(rowPath.getParent(), "transpose-" + (System.nanoTime() & 0xFF)); Configuration initialConf = getConf() == null ? new Configuration() : getConf(); Configuration conf = Tr... | DistributedRowMatrix implements VectorIterable, Configurable { public DistributedRowMatrix transpose() throws IOException { Path outputPath = new Path(rowPath.getParent(), "transpose-" + (System.nanoTime() & 0xFF)); Configuration initialConf = getConf() == null ? new Configuration() : getConf(); Configuration conf = Tr... | DistributedRowMatrix implements VectorIterable, Configurable { public DistributedRowMatrix transpose() throws IOException { Path outputPath = new Path(rowPath.getParent(), "transpose-" + (System.nanoTime() & 0xFF)); Configuration initialConf = getConf() == null ? new Configuration() : getConf(); Configuration conf = Tr... | DistributedRowMatrix implements VectorIterable, Configurable { public DistributedRowMatrix transpose() throws IOException { Path outputPath = new Path(rowPath.getParent(), "transpose-" + (System.nanoTime() & 0xFF)); Configuration initialConf = getConf() == null ? new Configuration() : getConf(); Configuration conf = Tr... |
@Test public void testMatrixTimesVector() throws Exception { Vector v = new RandomAccessSparseVector(50); v.assign(1.0); Matrix m = SolverTest.randomSequentialAccessSparseMatrix(100, 90, 50, 20, 1.0); DistributedRowMatrix dm = randomDistributedMatrix(100, 90, 50, 20, 1.0, false); Vector expected = m.times(v); Vector ac... | public DistributedRowMatrix times(DistributedRowMatrix other) throws IOException { return times(other, new Path(outputTmpBasePath.getParent(), "productWith-" + (System.nanoTime() & 0xFF))); } | DistributedRowMatrix implements VectorIterable, Configurable { public DistributedRowMatrix times(DistributedRowMatrix other) throws IOException { return times(other, new Path(outputTmpBasePath.getParent(), "productWith-" + (System.nanoTime() & 0xFF))); } } | DistributedRowMatrix implements VectorIterable, Configurable { public DistributedRowMatrix times(DistributedRowMatrix other) throws IOException { return times(other, new Path(outputTmpBasePath.getParent(), "productWith-" + (System.nanoTime() & 0xFF))); } DistributedRowMatrix(Path inputPath,
... | DistributedRowMatrix implements VectorIterable, Configurable { public DistributedRowMatrix times(DistributedRowMatrix other) throws IOException { return times(other, new Path(outputTmpBasePath.getParent(), "productWith-" + (System.nanoTime() & 0xFF))); } DistributedRowMatrix(Path inputPath,
... | DistributedRowMatrix implements VectorIterable, Configurable { public DistributedRowMatrix times(DistributedRowMatrix other) throws IOException { return times(other, new Path(outputTmpBasePath.getParent(), "productWith-" + (System.nanoTime() & 0xFF))); } DistributedRowMatrix(Path inputPath,
... |
@Test public void testMatrixTimesSquaredVector() throws Exception { Vector v = new RandomAccessSparseVector(50); v.assign(1.0); Matrix m = SolverTest.randomSequentialAccessSparseMatrix(100, 90, 50, 20, 1.0); DistributedRowMatrix dm = randomDistributedMatrix(100, 90, 50, 20, 1.0, false); Vector expected = m.timesSquared... | @Override public Vector timesSquared(Vector v) { try { Configuration initialConf = getConf() == null ? new Configuration() : getConf(); Path outputVectorTmpPath = new Path(outputTmpBasePath, new Path(Long.toString(System.nanoTime()))); Configuration conf = TimesSquaredJob.createTimesSquaredJobConf(initialConf, v, rowPa... | DistributedRowMatrix implements VectorIterable, Configurable { @Override public Vector timesSquared(Vector v) { try { Configuration initialConf = getConf() == null ? new Configuration() : getConf(); Path outputVectorTmpPath = new Path(outputTmpBasePath, new Path(Long.toString(System.nanoTime()))); Configuration conf = ... | DistributedRowMatrix implements VectorIterable, Configurable { @Override public Vector timesSquared(Vector v) { try { Configuration initialConf = getConf() == null ? new Configuration() : getConf(); Path outputVectorTmpPath = new Path(outputTmpBasePath, new Path(Long.toString(System.nanoTime()))); Configuration conf = ... | DistributedRowMatrix implements VectorIterable, Configurable { @Override public Vector timesSquared(Vector v) { try { Configuration initialConf = getConf() == null ? new Configuration() : getConf(); Path outputVectorTmpPath = new Path(outputTmpBasePath, new Path(Long.toString(System.nanoTime()))); Configuration conf = ... | DistributedRowMatrix implements VectorIterable, Configurable { @Override public Vector timesSquared(Vector v) { try { Configuration initialConf = getConf() == null ? new Configuration() : getConf(); Path outputVectorTmpPath = new Path(outputTmpBasePath, new Path(Long.toString(System.nanoTime()))); Configuration conf = ... |
@Test public void testRun() throws Exception { Path input = getTestTempDirPath("input"); Path output = getTestTempDirPath("output"); Path seedsPath = getTestTempDirPath("seeds"); List<VectorWritable> points = getPointsWritable(REFERENCE); List<VectorWritable> seeds = getPointsWritable(SEEDS); Configuration conf = new C... | @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption(DefaultOptionCreator.distanceMeasureOption().create()); addOption(SEEDS, "s", "The set of vectors to compute distances against. Must fit in memory on the mapper"); addOption(MAX_DISTANCE, "mx", "set an upper-bound ... | VectorDistanceSimilarityJob extends AbstractJob { @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption(DefaultOptionCreator.distanceMeasureOption().create()); addOption(SEEDS, "s", "The set of vectors to compute distances against. Must fit in memory on the mapper"); ... | VectorDistanceSimilarityJob extends AbstractJob { @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption(DefaultOptionCreator.distanceMeasureOption().create()); addOption(SEEDS, "s", "The set of vectors to compute distances against. Must fit in memory on the mapper"); ... | VectorDistanceSimilarityJob extends AbstractJob { @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption(DefaultOptionCreator.distanceMeasureOption().create()); addOption(SEEDS, "s", "The set of vectors to compute distances against. Must fit in memory on the mapper"); ... | VectorDistanceSimilarityJob extends AbstractJob { @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption(DefaultOptionCreator.distanceMeasureOption().create()); addOption(SEEDS, "s", "The set of vectors to compute distances against. Must fit in memory on the mapper"); ... |
@Test public void testMaxDistance() throws Exception { Path input = getTestTempDirPath("input"); Path output = getTestTempDirPath("output"); Path seedsPath = getTestTempDirPath("seeds"); List<VectorWritable> points = getPointsWritable(REFERENCE); List<VectorWritable> seeds = getPointsWritable(SEEDS); Configuration conf... | @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption(DefaultOptionCreator.distanceMeasureOption().create()); addOption(SEEDS, "s", "The set of vectors to compute distances against. Must fit in memory on the mapper"); addOption(MAX_DISTANCE, "mx", "set an upper-bound ... | VectorDistanceSimilarityJob extends AbstractJob { @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption(DefaultOptionCreator.distanceMeasureOption().create()); addOption(SEEDS, "s", "The set of vectors to compute distances against. Must fit in memory on the mapper"); ... | VectorDistanceSimilarityJob extends AbstractJob { @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption(DefaultOptionCreator.distanceMeasureOption().create()); addOption(SEEDS, "s", "The set of vectors to compute distances against. Must fit in memory on the mapper"); ... | VectorDistanceSimilarityJob extends AbstractJob { @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption(DefaultOptionCreator.distanceMeasureOption().create()); addOption(SEEDS, "s", "The set of vectors to compute distances against. Must fit in memory on the mapper"); ... | VectorDistanceSimilarityJob extends AbstractJob { @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption(DefaultOptionCreator.distanceMeasureOption().create()); addOption(SEEDS, "s", "The set of vectors to compute distances against. Must fit in memory on the mapper"); ... |
@Test public void testRunInverted() throws Exception { Path input = getTestTempDirPath("input"); Path output = getTestTempDirPath("output"); Path seedsPath = getTestTempDirPath("seeds"); List<VectorWritable> points = getPointsWritable(REFERENCE); List<VectorWritable> seeds = getPointsWritable(SEEDS); Configuration conf... | @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption(DefaultOptionCreator.distanceMeasureOption().create()); addOption(SEEDS, "s", "The set of vectors to compute distances against. Must fit in memory on the mapper"); addOption(MAX_DISTANCE, "mx", "set an upper-bound ... | VectorDistanceSimilarityJob extends AbstractJob { @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption(DefaultOptionCreator.distanceMeasureOption().create()); addOption(SEEDS, "s", "The set of vectors to compute distances against. Must fit in memory on the mapper"); ... | VectorDistanceSimilarityJob extends AbstractJob { @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption(DefaultOptionCreator.distanceMeasureOption().create()); addOption(SEEDS, "s", "The set of vectors to compute distances against. Must fit in memory on the mapper"); ... | VectorDistanceSimilarityJob extends AbstractJob { @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption(DefaultOptionCreator.distanceMeasureOption().create()); addOption(SEEDS, "s", "The set of vectors to compute distances against. Must fit in memory on the mapper"); ... | VectorDistanceSimilarityJob extends AbstractJob { @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption(DefaultOptionCreator.distanceMeasureOption().create()); addOption(SEEDS, "s", "The set of vectors to compute distances against. Must fit in memory on the mapper"); ... |
@Test public void toyIntegration() throws Exception { File inputFile = getTestTempFile("rows"); File outputDir = getTestTempDir("output"); outputDir.delete(); File tmpDir = getTestTempDir("tmp"); Configuration conf = new Configuration(); Path inputPath = new Path(inputFile.getAbsolutePath()); FileSystem fs = FileSystem... | @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption("numberOfColumns", "r", "Number of columns in the input matrix", false); addOption("similarityClassname", "s", "Name of distributed similarity class to instantiate, alternatively use " + "one of the predefined simi... | RowSimilarityJob extends AbstractJob { @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption("numberOfColumns", "r", "Number of columns in the input matrix", false); addOption("similarityClassname", "s", "Name of distributed similarity class to instantiate, alternativ... | RowSimilarityJob extends AbstractJob { @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption("numberOfColumns", "r", "Number of columns in the input matrix", false); addOption("similarityClassname", "s", "Name of distributed similarity class to instantiate, alternativ... | RowSimilarityJob extends AbstractJob { @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption("numberOfColumns", "r", "Number of columns in the input matrix", false); addOption("similarityClassname", "s", "Name of distributed similarity class to instantiate, alternativ... | RowSimilarityJob extends AbstractJob { @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption("numberOfColumns", "r", "Number of columns in the input matrix", false); addOption("similarityClassname", "s", "Name of distributed similarity class to instantiate, alternativ... |
@Test public void toyIntegrationMaxSimilaritiesPerRow() throws Exception { File inputFile = getTestTempFile("rows"); File outputDir = getTestTempDir("output"); outputDir.delete(); File tmpDir = getTestTempDir("tmp"); Configuration conf = new Configuration(); Path inputPath = new Path(inputFile.getAbsolutePath()); FileS... | @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption("numberOfColumns", "r", "Number of columns in the input matrix", false); addOption("similarityClassname", "s", "Name of distributed similarity class to instantiate, alternatively use " + "one of the predefined simi... | RowSimilarityJob extends AbstractJob { @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption("numberOfColumns", "r", "Number of columns in the input matrix", false); addOption("similarityClassname", "s", "Name of distributed similarity class to instantiate, alternativ... | RowSimilarityJob extends AbstractJob { @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption("numberOfColumns", "r", "Number of columns in the input matrix", false); addOption("similarityClassname", "s", "Name of distributed similarity class to instantiate, alternativ... | RowSimilarityJob extends AbstractJob { @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption("numberOfColumns", "r", "Number of columns in the input matrix", false); addOption("similarityClassname", "s", "Name of distributed similarity class to instantiate, alternativ... | RowSimilarityJob extends AbstractJob { @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption("numberOfColumns", "r", "Number of columns in the input matrix", false); addOption("similarityClassname", "s", "Name of distributed similarity class to instantiate, alternativ... |
@Test public void toyIntegrationWithThreshold() throws Exception { File inputFile = getTestTempFile("rows"); File outputDir = getTestTempDir("output"); outputDir.delete(); File tmpDir = getTestTempDir("tmp"); Configuration conf = new Configuration(); Path inputPath = new Path(inputFile.getAbsolutePath()); FileSystem fs... | @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption("numberOfColumns", "r", "Number of columns in the input matrix", false); addOption("similarityClassname", "s", "Name of distributed similarity class to instantiate, alternatively use " + "one of the predefined simi... | RowSimilarityJob extends AbstractJob { @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption("numberOfColumns", "r", "Number of columns in the input matrix", false); addOption("similarityClassname", "s", "Name of distributed similarity class to instantiate, alternativ... | RowSimilarityJob extends AbstractJob { @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption("numberOfColumns", "r", "Number of columns in the input matrix", false); addOption("similarityClassname", "s", "Name of distributed similarity class to instantiate, alternativ... | RowSimilarityJob extends AbstractJob { @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption("numberOfColumns", "r", "Number of columns in the input matrix", false); addOption("similarityClassname", "s", "Name of distributed similarity class to instantiate, alternativ... | RowSimilarityJob extends AbstractJob { @Override public int run(String[] args) throws Exception { addInputOption(); addOutputOption(); addOption("numberOfColumns", "r", "Number of columns in the input matrix", false); addOption("similarityClassname", "s", "Name of distributed similarity class to instantiate, alternativ... |
@Test public void testGet() { for (int i = 0; i < test.size(); i++) { if (i % 2 == 0) { assertEquals("get [" + i + ']', 0.0, test.get(i), EPSILON); } else { assertEquals("get [" + i + ']', values[i/2], test.get(i), EPSILON); } } } | @Override public double get(int index) { if (index < 0 || index >= size) { throw new IndexException(index, size); } return getQuick(index); } | AbstractVector implements Vector, LengthCachingVector { @Override public double get(int index) { if (index < 0 || index >= size) { throw new IndexException(index, size); } return getQuick(index); } } | AbstractVector implements Vector, LengthCachingVector { @Override public double get(int index) { if (index < 0 || index >= size) { throw new IndexException(index, size); } return getQuick(index); } protected AbstractVector(int size); } | AbstractVector implements Vector, LengthCachingVector { @Override public double get(int index) { if (index < 0 || index >= size) { throw new IndexException(index, size); } return getQuick(index); } protected AbstractVector(int size); @Override double aggregate(DoubleDoubleFunction aggregator, DoubleFunction map); @Ove... | AbstractVector implements Vector, LengthCachingVector { @Override public double get(int index) { if (index < 0 || index >= size) { throw new IndexException(index, size); } return getQuick(index); } protected AbstractVector(int size); @Override double aggregate(DoubleDoubleFunction aggregator, DoubleFunction map); @Ove... |
@Test public void testConditionalEntropy() throws Exception { Configuration configuration = new Configuration(); Path input = getTestTempFilePath("input"); Path output = getTestTempFilePath("output"); FileSystem fileSystem = FileSystem.get(input.toUri(), configuration); String[] keys = { "Math", "History", "CS", "Math"... | @Override public int run(String[] args) throws IOException, ClassNotFoundException, InterruptedException { prepareArguments(args); groupAndCountByKeyAndValue(); calculateSpecificConditionalEntropy(); calculateConditionalEntropy(); return 0; } | ConditionalEntropy extends AbstractJob { @Override public int run(String[] args) throws IOException, ClassNotFoundException, InterruptedException { prepareArguments(args); groupAndCountByKeyAndValue(); calculateSpecificConditionalEntropy(); calculateConditionalEntropy(); return 0; } } | ConditionalEntropy extends AbstractJob { @Override public int run(String[] args) throws IOException, ClassNotFoundException, InterruptedException { prepareArguments(args); groupAndCountByKeyAndValue(); calculateSpecificConditionalEntropy(); calculateConditionalEntropy(); return 0; } } | ConditionalEntropy extends AbstractJob { @Override public int run(String[] args) throws IOException, ClassNotFoundException, InterruptedException { prepareArguments(args); groupAndCountByKeyAndValue(); calculateSpecificConditionalEntropy(); calculateConditionalEntropy(); return 0; } static void main(String[] args); @O... | ConditionalEntropy extends AbstractJob { @Override public int run(String[] args) throws IOException, ClassNotFoundException, InterruptedException { prepareArguments(args); groupAndCountByKeyAndValue(); calculateSpecificConditionalEntropy(); calculateConditionalEntropy(); return 0; } static void main(String[] args); @O... |
@Test public void testLetters() throws Exception { String[] content = { "A", "A", "A", "A", "A", "B", "B", "C", "D", "E" }; calculateEntropy(content, 1.96096405, "key"); } | private void calculateEntropy() throws IOException, ClassNotFoundException, InterruptedException { Job job = prepareJob(tempPath, getOutputPath(), SequenceFileInputFormat.class, CalculateEntropyMapper.class, NullWritable.class, DoubleWritable.class, CalculateEntropyReducer.class, NullWritable.class, DoubleWritable.clas... | Entropy extends AbstractJob { private void calculateEntropy() throws IOException, ClassNotFoundException, InterruptedException { Job job = prepareJob(tempPath, getOutputPath(), SequenceFileInputFormat.class, CalculateEntropyMapper.class, NullWritable.class, DoubleWritable.class, CalculateEntropyReducer.class, NullWrita... | Entropy extends AbstractJob { private void calculateEntropy() throws IOException, ClassNotFoundException, InterruptedException { Job job = prepareJob(tempPath, getOutputPath(), SequenceFileInputFormat.class, CalculateEntropyMapper.class, NullWritable.class, DoubleWritable.class, CalculateEntropyReducer.class, NullWrita... | Entropy extends AbstractJob { private void calculateEntropy() throws IOException, ClassNotFoundException, InterruptedException { Job job = prepareJob(tempPath, getOutputPath(), SequenceFileInputFormat.class, CalculateEntropyMapper.class, NullWritable.class, DoubleWritable.class, CalculateEntropyReducer.class, NullWrita... | Entropy extends AbstractJob { private void calculateEntropy() throws IOException, ClassNotFoundException, InterruptedException { Job job = prepareJob(tempPath, getOutputPath(), SequenceFileInputFormat.class, CalculateEntropyMapper.class, NullWritable.class, DoubleWritable.class, CalculateEntropyReducer.class, NullWrita... |
@Test public void testYN() throws Exception { String[] content = { "Yes", "No", "Yes", "No", "No", "Yes", "No", "Yes" }; calculateEntropy(content, 1.0, "value"); } | private void calculateEntropy() throws IOException, ClassNotFoundException, InterruptedException { Job job = prepareJob(tempPath, getOutputPath(), SequenceFileInputFormat.class, CalculateEntropyMapper.class, NullWritable.class, DoubleWritable.class, CalculateEntropyReducer.class, NullWritable.class, DoubleWritable.clas... | Entropy extends AbstractJob { private void calculateEntropy() throws IOException, ClassNotFoundException, InterruptedException { Job job = prepareJob(tempPath, getOutputPath(), SequenceFileInputFormat.class, CalculateEntropyMapper.class, NullWritable.class, DoubleWritable.class, CalculateEntropyReducer.class, NullWrita... | Entropy extends AbstractJob { private void calculateEntropy() throws IOException, ClassNotFoundException, InterruptedException { Job job = prepareJob(tempPath, getOutputPath(), SequenceFileInputFormat.class, CalculateEntropyMapper.class, NullWritable.class, DoubleWritable.class, CalculateEntropyReducer.class, NullWrita... | Entropy extends AbstractJob { private void calculateEntropy() throws IOException, ClassNotFoundException, InterruptedException { Job job = prepareJob(tempPath, getOutputPath(), SequenceFileInputFormat.class, CalculateEntropyMapper.class, NullWritable.class, DoubleWritable.class, CalculateEntropyReducer.class, NullWrita... | Entropy extends AbstractJob { private void calculateEntropy() throws IOException, ClassNotFoundException, InterruptedException { Job job = prepareJob(tempPath, getOutputPath(), SequenceFileInputFormat.class, CalculateEntropyMapper.class, NullWritable.class, DoubleWritable.class, CalculateEntropyReducer.class, NullWrita... |
@Test public void createStandardAnalyzer() throws Exception { assertNotNull(AnalyzerUtils.createAnalyzer(StandardAnalyzer.class.getName())); } | public static Analyzer createAnalyzer(String analyzerClassName) throws ClassNotFoundException { return createAnalyzer(analyzerClassName, Version.LUCENE_42); } | AnalyzerUtils { public static Analyzer createAnalyzer(String analyzerClassName) throws ClassNotFoundException { return createAnalyzer(analyzerClassName, Version.LUCENE_42); } } | AnalyzerUtils { public static Analyzer createAnalyzer(String analyzerClassName) throws ClassNotFoundException { return createAnalyzer(analyzerClassName, Version.LUCENE_42); } private AnalyzerUtils(); } | AnalyzerUtils { public static Analyzer createAnalyzer(String analyzerClassName) throws ClassNotFoundException { return createAnalyzer(analyzerClassName, Version.LUCENE_42); } private AnalyzerUtils(); static Analyzer createAnalyzer(String analyzerClassName); static Analyzer createAnalyzer(String analyzerClassName, Vers... | AnalyzerUtils { public static Analyzer createAnalyzer(String analyzerClassName) throws ClassNotFoundException { return createAnalyzer(analyzerClassName, Version.LUCENE_42); } private AnalyzerUtils(); static Analyzer createAnalyzer(String analyzerClassName); static Analyzer createAnalyzer(String analyzerClassName, Vers... |
@Test public void createCJKAnalyzer() throws Exception { assertNotNull(AnalyzerUtils.createAnalyzer(CJKAnalyzer.class.getName())); } | public static Analyzer createAnalyzer(String analyzerClassName) throws ClassNotFoundException { return createAnalyzer(analyzerClassName, Version.LUCENE_42); } | AnalyzerUtils { public static Analyzer createAnalyzer(String analyzerClassName) throws ClassNotFoundException { return createAnalyzer(analyzerClassName, Version.LUCENE_42); } } | AnalyzerUtils { public static Analyzer createAnalyzer(String analyzerClassName) throws ClassNotFoundException { return createAnalyzer(analyzerClassName, Version.LUCENE_42); } private AnalyzerUtils(); } | AnalyzerUtils { public static Analyzer createAnalyzer(String analyzerClassName) throws ClassNotFoundException { return createAnalyzer(analyzerClassName, Version.LUCENE_42); } private AnalyzerUtils(); static Analyzer createAnalyzer(String analyzerClassName); static Analyzer createAnalyzer(String analyzerClassName, Vers... | AnalyzerUtils { public static Analyzer createAnalyzer(String analyzerClassName) throws ClassNotFoundException { return createAnalyzer(analyzerClassName, Version.LUCENE_42); } private AnalyzerUtils(); static Analyzer createAnalyzer(String analyzerClassName); static Analyzer createAnalyzer(String analyzerClassName, Vers... |
@Test public void testMeasure() { DistanceMeasure distanceMeasure = new CosineDistanceMeasure(); Vector[] vectors = { new DenseVector(new double[]{1, 0, 0, 0, 0, 0}), new DenseVector(new double[]{1, 1, 1, 0, 0, 0}), new DenseVector(new double[]{1, 1, 1, 1, 1, 1}) }; double[][] distanceMatrix = new double[3][3]; for (in... | public static double distance(double[] p1, double[] p2) { double dotProduct = 0.0; double lengthSquaredp1 = 0.0; double lengthSquaredp2 = 0.0; for (int i = 0; i < p1.length; i++) { lengthSquaredp1 += p1[i] * p1[i]; lengthSquaredp2 += p2[i] * p2[i]; dotProduct += p1[i] * p2[i]; } double denominator = Math.sqrt(lengthSqu... | CosineDistanceMeasure implements DistanceMeasure { public static double distance(double[] p1, double[] p2) { double dotProduct = 0.0; double lengthSquaredp1 = 0.0; double lengthSquaredp2 = 0.0; for (int i = 0; i < p1.length; i++) { lengthSquaredp1 += p1[i] * p1[i]; lengthSquaredp2 += p2[i] * p2[i]; dotProduct += p1[i] ... | CosineDistanceMeasure implements DistanceMeasure { public static double distance(double[] p1, double[] p2) { double dotProduct = 0.0; double lengthSquaredp1 = 0.0; double lengthSquaredp2 = 0.0; for (int i = 0; i < p1.length; i++) { lengthSquaredp1 += p1[i] * p1[i]; lengthSquaredp2 += p2[i] * p2[i]; dotProduct += p1[i] ... | CosineDistanceMeasure implements DistanceMeasure { public static double distance(double[] p1, double[] p2) { double dotProduct = 0.0; double lengthSquaredp1 = 0.0; double lengthSquaredp2 = 0.0; for (int i = 0; i < p1.length; i++) { lengthSquaredp1 += p1[i] * p1[i]; lengthSquaredp2 += p2[i] * p2[i]; dotProduct += p1[i] ... | CosineDistanceMeasure implements DistanceMeasure { public static double distance(double[] p1, double[] p2) { double dotProduct = 0.0; double lengthSquaredp1 = 0.0; double lengthSquaredp2 = 0.0; for (int i = 0; i < p1.length; i++) { lengthSquaredp1 += p1[i] * p1[i]; lengthSquaredp2 += p2[i] * p2[i]; dotProduct += p1[i] ... |
@Test public void testTrain() { Random gen = RandomUtils.getRandom(); Exponential exp = new Exponential(0.5, gen); Vector beta = new DenseVector(200); for (Vector.Element element : beta) { int sign = 1; if (gen.nextDouble() < 0.5) { sign = -1; } element.set(sign * exp.nextDouble()); } AdaptiveLogisticRegression.Wrapper... | @Override public void train(int actual, Vector instance) { train(record, null, actual, instance); } | AdaptiveLogisticRegression implements OnlineLearner, Writable { @Override public void train(int actual, Vector instance) { train(record, null, actual, instance); } } | AdaptiveLogisticRegression implements OnlineLearner, Writable { @Override public void train(int actual, Vector instance) { train(record, null, actual, instance); } AdaptiveLogisticRegression(); AdaptiveLogisticRegression(int numCategories, int numFeatures, PriorFunction prior); AdaptiveLogisticRegression(int numCateg... | AdaptiveLogisticRegression implements OnlineLearner, Writable { @Override public void train(int actual, Vector instance) { train(record, null, actual, instance); } AdaptiveLogisticRegression(); AdaptiveLogisticRegression(int numCategories, int numFeatures, PriorFunction prior); AdaptiveLogisticRegression(int numCateg... | AdaptiveLogisticRegression implements OnlineLearner, Writable { @Override public void train(int actual, Vector instance) { train(record, null, actual, instance); } AdaptiveLogisticRegression(); AdaptiveLogisticRegression(int numCategories, int numFeatures, PriorFunction prior); AdaptiveLogisticRegression(int numCateg... |
@Test public void testGenerateDataset() throws Exception { int nbAttributes = 10; int datasize = 100; String descriptor = Utils.randomDescriptor(rng, nbAttributes); Attribute[] attrs = DescriptorUtils.parseDescriptor(descriptor); double[][] data = Utils.randomDoubles(rng, descriptor, false, datasize); Collection<Intege... | public static Dataset generateDataset(CharSequence descriptor, boolean regression, FileSystem fs, Path path) throws DescriptorException, IOException { Attribute[] attrs = DescriptorUtils.parseDescriptor(descriptor); FSDataInputStream input = fs.open(path); Scanner scanner = new Scanner(input, "UTF-8"); @SuppressWarning... | DataLoader { public static Dataset generateDataset(CharSequence descriptor, boolean regression, FileSystem fs, Path path) throws DescriptorException, IOException { Attribute[] attrs = DescriptorUtils.parseDescriptor(descriptor); FSDataInputStream input = fs.open(path); Scanner scanner = new Scanner(input, "UTF-8"); @Su... | DataLoader { public static Dataset generateDataset(CharSequence descriptor, boolean regression, FileSystem fs, Path path) throws DescriptorException, IOException { Attribute[] attrs = DescriptorUtils.parseDescriptor(descriptor); FSDataInputStream input = fs.open(path); Scanner scanner = new Scanner(input, "UTF-8"); @Su... | DataLoader { public static Dataset generateDataset(CharSequence descriptor, boolean regression, FileSystem fs, Path path) throws DescriptorException, IOException { Attribute[] attrs = DescriptorUtils.parseDescriptor(descriptor); FSDataInputStream input = fs.open(path); Scanner scanner = new Scanner(input, "UTF-8"); @Su... | DataLoader { public static Dataset generateDataset(CharSequence descriptor, boolean regression, FileSystem fs, Path path) throws DescriptorException, IOException { Attribute[] attrs = DescriptorUtils.parseDescriptor(descriptor); FSDataInputStream input = fs.open(path); Scanner scanner = new Scanner(input, "UTF-8"); @Su... |
@Test public void testGenerateDatasetFromFile() throws Exception { int nbAttributes = 10; int datasize = 100; String descriptor = Utils.randomDescriptor(rng, nbAttributes); Attribute[] attrs = DescriptorUtils.parseDescriptor(descriptor); double[][] source = Utils.randomDoubles(rng, descriptor, false, datasize); Collect... | public static Dataset generateDataset(CharSequence descriptor, boolean regression, FileSystem fs, Path path) throws DescriptorException, IOException { Attribute[] attrs = DescriptorUtils.parseDescriptor(descriptor); FSDataInputStream input = fs.open(path); Scanner scanner = new Scanner(input, "UTF-8"); @SuppressWarning... | DataLoader { public static Dataset generateDataset(CharSequence descriptor, boolean regression, FileSystem fs, Path path) throws DescriptorException, IOException { Attribute[] attrs = DescriptorUtils.parseDescriptor(descriptor); FSDataInputStream input = fs.open(path); Scanner scanner = new Scanner(input, "UTF-8"); @Su... | DataLoader { public static Dataset generateDataset(CharSequence descriptor, boolean regression, FileSystem fs, Path path) throws DescriptorException, IOException { Attribute[] attrs = DescriptorUtils.parseDescriptor(descriptor); FSDataInputStream input = fs.open(path); Scanner scanner = new Scanner(input, "UTF-8"); @Su... | DataLoader { public static Dataset generateDataset(CharSequence descriptor, boolean regression, FileSystem fs, Path path) throws DescriptorException, IOException { Attribute[] attrs = DescriptorUtils.parseDescriptor(descriptor); FSDataInputStream input = fs.open(path); Scanner scanner = new Scanner(input, "UTF-8"); @Su... | DataLoader { public static Dataset generateDataset(CharSequence descriptor, boolean regression, FileSystem fs, Path path) throws DescriptorException, IOException { Attribute[] attrs = DescriptorUtils.parseDescriptor(descriptor); FSDataInputStream input = fs.open(path); Scanner scanner = new Scanner(input, "UTF-8"); @Su... |
@Test public void testClassify() throws DescriptorException { Data[] datas = generateTrainingDataA(); DecisionForest forest = buildForest(datas); Data testData = DataLoader.loadData(datas[0].getDataset(), TEST_DATA); assertEquals(1.0, forest.classify(testData.getDataset(), rng, testData.get(0)), EPSILON); assertEquals(... | public void classify(Data data, double[][] predictions) { Preconditions.checkArgument(data.size() == predictions.length, "predictions.length must be equal to data.size()"); if (data.isEmpty()) { return; } int treeId = 0; for (Node tree : trees) { for (int index = 0; index < data.size(); index++) { if (predictions[index... | DecisionForest implements Writable { public void classify(Data data, double[][] predictions) { Preconditions.checkArgument(data.size() == predictions.length, "predictions.length must be equal to data.size()"); if (data.isEmpty()) { return; } int treeId = 0; for (Node tree : trees) { for (int index = 0; index < data.siz... | DecisionForest implements Writable { public void classify(Data data, double[][] predictions) { Preconditions.checkArgument(data.size() == predictions.length, "predictions.length must be equal to data.size()"); if (data.isEmpty()) { return; } int treeId = 0; for (Node tree : trees) { for (int index = 0; index < data.siz... | DecisionForest implements Writable { public void classify(Data data, double[][] predictions) { Preconditions.checkArgument(data.size() == predictions.length, "predictions.length must be equal to data.size()"); if (data.isEmpty()) { return; } int treeId = 0; for (Node tree : trees) { for (int index = 0; index < data.siz... | DecisionForest implements Writable { public void classify(Data data, double[][] predictions) { Preconditions.checkArgument(data.size() == predictions.length, "predictions.length must be equal to data.size()"); if (data.isEmpty()) { return; } int treeId = 0; for (Node tree : trees) { for (int index = 0; index < data.siz... |
@Test public void testClassifyData() throws DescriptorException { Data[] datas = generateTrainingDataA(); DecisionForest forest = buildForest(datas); Data testData = DataLoader.loadData(datas[0].getDataset(), TEST_DATA); double[][] predictions = new double[testData.size()][]; forest.classify(testData, predictions); ass... | public void classify(Data data, double[][] predictions) { Preconditions.checkArgument(data.size() == predictions.length, "predictions.length must be equal to data.size()"); if (data.isEmpty()) { return; } int treeId = 0; for (Node tree : trees) { for (int index = 0; index < data.size(); index++) { if (predictions[index... | DecisionForest implements Writable { public void classify(Data data, double[][] predictions) { Preconditions.checkArgument(data.size() == predictions.length, "predictions.length must be equal to data.size()"); if (data.isEmpty()) { return; } int treeId = 0; for (Node tree : trees) { for (int index = 0; index < data.siz... | DecisionForest implements Writable { public void classify(Data data, double[][] predictions) { Preconditions.checkArgument(data.size() == predictions.length, "predictions.length must be equal to data.size()"); if (data.isEmpty()) { return; } int treeId = 0; for (Node tree : trees) { for (int index = 0; index < data.siz... | DecisionForest implements Writable { public void classify(Data data, double[][] predictions) { Preconditions.checkArgument(data.size() == predictions.length, "predictions.length must be equal to data.size()"); if (data.isEmpty()) { return; } int treeId = 0; for (Node tree : trees) { for (int index = 0; index < data.siz... | DecisionForest implements Writable { public void classify(Data data, double[][] predictions) { Preconditions.checkArgument(data.size() == predictions.length, "predictions.length must be equal to data.size()"); if (data.isEmpty()) { return; } int treeId = 0; for (Node tree : trees) { for (int index = 0; index < data.siz... |
@Test public void testRegression() throws DescriptorException { Data[] datas = generateTrainingDataB(); DecisionForest[] forests = new DecisionForest[datas.length]; for (int i = 0; i < datas.length; i++) { Data[] subDatas = new Data[datas.length - 1]; int k = 0; for (int j = 0; j < datas.length; j++) { if (j != i) { su... | public void classify(Data data, double[][] predictions) { Preconditions.checkArgument(data.size() == predictions.length, "predictions.length must be equal to data.size()"); if (data.isEmpty()) { return; } int treeId = 0; for (Node tree : trees) { for (int index = 0; index < data.size(); index++) { if (predictions[index... | DecisionForest implements Writable { public void classify(Data data, double[][] predictions) { Preconditions.checkArgument(data.size() == predictions.length, "predictions.length must be equal to data.size()"); if (data.isEmpty()) { return; } int treeId = 0; for (Node tree : trees) { for (int index = 0; index < data.siz... | DecisionForest implements Writable { public void classify(Data data, double[][] predictions) { Preconditions.checkArgument(data.size() == predictions.length, "predictions.length must be equal to data.size()"); if (data.isEmpty()) { return; } int treeId = 0; for (Node tree : trees) { for (int index = 0; index < data.siz... | DecisionForest implements Writable { public void classify(Data data, double[][] predictions) { Preconditions.checkArgument(data.size() == predictions.length, "predictions.length must be equal to data.size()"); if (data.isEmpty()) { return; } int treeId = 0; for (Node tree : trees) { for (int index = 0; index < data.siz... | DecisionForest implements Writable { public void classify(Data data, double[][] predictions) { Preconditions.checkArgument(data.size() == predictions.length, "predictions.length must be equal to data.size()"); if (data.isEmpty()) { return; } int treeId = 0; for (Node tree : trees) { for (int index = 0; index < data.siz... |
@Test public void testSplits() throws Exception { int n = 1; int maxNumSplits = 100; int maxNbTrees = 1000; Random rng = RandomUtils.getRandom(); for (int nloop = 0; nloop < n; nloop++) { int numSplits = rng.nextInt(maxNumSplits) + 1; int nbTrees = rng.nextInt(maxNbTrees) + 1; Configuration conf = new Configuration(); ... | @Override public List<InputSplit> getSplits(JobContext context) throws IOException, InterruptedException { Configuration conf = context.getConfiguration(); int numSplits = conf.getInt("mapred.map.tasks", -1); return getSplits(conf, numSplits); } | InMemInputFormat extends InputFormat<IntWritable,NullWritable> { @Override public List<InputSplit> getSplits(JobContext context) throws IOException, InterruptedException { Configuration conf = context.getConfiguration(); int numSplits = conf.getInt("mapred.map.tasks", -1); return getSplits(conf, numSplits); } } | InMemInputFormat extends InputFormat<IntWritable,NullWritable> { @Override public List<InputSplit> getSplits(JobContext context) throws IOException, InterruptedException { Configuration conf = context.getConfiguration(); int numSplits = conf.getInt("mapred.map.tasks", -1); return getSplits(conf, numSplits); } } | InMemInputFormat extends InputFormat<IntWritable,NullWritable> { @Override public List<InputSplit> getSplits(JobContext context) throws IOException, InterruptedException { Configuration conf = context.getConfiguration(); int numSplits = conf.getInt("mapred.map.tasks", -1); return getSplits(conf, numSplits); } @Overrid... | InMemInputFormat extends InputFormat<IntWritable,NullWritable> { @Override public List<InputSplit> getSplits(JobContext context) throws IOException, InterruptedException { Configuration conf = context.getConfiguration(); int numSplits = conf.getInt("mapred.map.tasks", -1); return getSplits(conf, numSplits); } @Overrid... |
@Test public void testRecordReader() throws Exception { int n = 1; int maxNumSplits = 100; int maxNbTrees = 1000; Random rng = RandomUtils.getRandom(); for (int nloop = 0; nloop < n; nloop++) { int numSplits = rng.nextInt(maxNumSplits) + 1; int nbTrees = rng.nextInt(maxNbTrees) + 1; Configuration conf = new Configurati... | @Override public List<InputSplit> getSplits(JobContext context) throws IOException, InterruptedException { Configuration conf = context.getConfiguration(); int numSplits = conf.getInt("mapred.map.tasks", -1); return getSplits(conf, numSplits); } | InMemInputFormat extends InputFormat<IntWritable,NullWritable> { @Override public List<InputSplit> getSplits(JobContext context) throws IOException, InterruptedException { Configuration conf = context.getConfiguration(); int numSplits = conf.getInt("mapred.map.tasks", -1); return getSplits(conf, numSplits); } } | InMemInputFormat extends InputFormat<IntWritable,NullWritable> { @Override public List<InputSplit> getSplits(JobContext context) throws IOException, InterruptedException { Configuration conf = context.getConfiguration(); int numSplits = conf.getInt("mapred.map.tasks", -1); return getSplits(conf, numSplits); } } | InMemInputFormat extends InputFormat<IntWritable,NullWritable> { @Override public List<InputSplit> getSplits(JobContext context) throws IOException, InterruptedException { Configuration conf = context.getConfiguration(); int numSplits = conf.getInt("mapred.map.tasks", -1); return getSplits(conf, numSplits); } @Overrid... | InMemInputFormat extends InputFormat<IntWritable,NullWritable> { @Override public List<InputSplit> getSplits(JobContext context) throws IOException, InterruptedException { Configuration conf = context.getConfiguration(); int numSplits = conf.getInt("mapred.map.tasks", -1); return getSplits(conf, numSplits); } @Overrid... |
@Test public void testClassify() { double[] valuesFalse = {1.0, 0.0, 1.0, 0.0, 1.0}; Vector dataPointFalse = new DenseVector(valuesFalse); assertFalse(this.model.classify(dataPointFalse)); double[] valuesTrue = {0.0, 1.0, 0.0, 1.0, 0.0}; Vector dataPointTrue = new DenseVector(valuesTrue); assertTrue(this.model.classify... | public boolean classify(Vector dataPoint) { double product = this.hyperplane.dot(dataPoint); if (log.isDebugEnabled()) { log.debug("model: {} product: {} Bias: {} threshold: {}", this, product, bias, threshold); } return product + this.bias > this.threshold; } | LinearModel { public boolean classify(Vector dataPoint) { double product = this.hyperplane.dot(dataPoint); if (log.isDebugEnabled()) { log.debug("model: {} product: {} Bias: {} threshold: {}", this, product, bias, threshold); } return product + this.bias > this.threshold; } } | LinearModel { public boolean classify(Vector dataPoint) { double product = this.hyperplane.dot(dataPoint); if (log.isDebugEnabled()) { log.debug("model: {} product: {} Bias: {} threshold: {}", this, product, bias, threshold); } return product + this.bias > this.threshold; } LinearModel(Vector hyperplane, double displac... | LinearModel { public boolean classify(Vector dataPoint) { double product = this.hyperplane.dot(dataPoint); if (log.isDebugEnabled()) { log.debug("model: {} product: {} Bias: {} threshold: {}", this, product, bias, threshold); } return product + this.bias > this.threshold; } LinearModel(Vector hyperplane, double displac... | LinearModel { public boolean classify(Vector dataPoint) { double product = this.hyperplane.dot(dataPoint); if (log.isDebugEnabled()) { log.debug("model: {} product: {} Bias: {} threshold: {}", this, product, bias, threshold); } return product + this.bias > this.threshold; } LinearModel(Vector hyperplane, double displac... |
@Test public void testRandomModelGeneration() { NaiveBayesModel model = getModel(); model.validate(); } | public void validate() { Preconditions.checkState(alphaI > 0, "alphaI has to be greater than 0!"); Preconditions.checkArgument(numFeatures > 0, "the vocab count has to be greater than 0!"); Preconditions.checkArgument(totalWeightSum > 0, "the totalWeightSum has to be greater than 0!"); Preconditions.checkNotNull(weight... | NaiveBayesModel { public void validate() { Preconditions.checkState(alphaI > 0, "alphaI has to be greater than 0!"); Preconditions.checkArgument(numFeatures > 0, "the vocab count has to be greater than 0!"); Preconditions.checkArgument(totalWeightSum > 0, "the totalWeightSum has to be greater than 0!"); Preconditions.c... | NaiveBayesModel { public void validate() { Preconditions.checkState(alphaI > 0, "alphaI has to be greater than 0!"); Preconditions.checkArgument(numFeatures > 0, "the vocab count has to be greater than 0!"); Preconditions.checkArgument(totalWeightSum > 0, "the totalWeightSum has to be greater than 0!"); Preconditions.c... | NaiveBayesModel { public void validate() { Preconditions.checkState(alphaI > 0, "alphaI has to be greater than 0!"); Preconditions.checkArgument(numFeatures > 0, "the vocab count has to be greater than 0!"); Preconditions.checkArgument(totalWeightSum > 0, "the totalWeightSum has to be greater than 0!"); Preconditions.c... | NaiveBayesModel { public void validate() { Preconditions.checkState(alphaI > 0, "alphaI has to be greater than 0!"); Preconditions.checkArgument(numFeatures > 0, "the vocab count has to be greater than 0!"); Preconditions.checkArgument(totalWeightSum > 0, "the totalWeightSum has to be greater than 0!"); Preconditions.c... |
@Test public void testGetMatrix() { ConfusionMatrix cm = fillCM(VALUES, LABELS, DEFAULT_LABEL); Matrix m = cm.getMatrix(); Map<String, Integer> rowLabels = m.getRowLabelBindings(); assertEquals(cm.getLabels().size(), m.numCols()); assertTrue(rowLabels.keySet().contains(LABELS[0])); assertTrue(rowLabels.keySet().contain... | public Matrix getMatrix() { int length = confusionMatrix.length; Matrix m = new DenseMatrix(length, length); for (int r = 0; r < length; r++) { for (int c = 0; c < length; c++) { m.set(r, c, confusionMatrix[r][c]); } } Map<String,Integer> labels = Maps.newHashMap(); for (Map.Entry<String, Integer> entry : labelMap.entr... | ConfusionMatrix { public Matrix getMatrix() { int length = confusionMatrix.length; Matrix m = new DenseMatrix(length, length); for (int r = 0; r < length; r++) { for (int c = 0; c < length; c++) { m.set(r, c, confusionMatrix[r][c]); } } Map<String,Integer> labels = Maps.newHashMap(); for (Map.Entry<String, Integer> ent... | ConfusionMatrix { public Matrix getMatrix() { int length = confusionMatrix.length; Matrix m = new DenseMatrix(length, length); for (int r = 0; r < length; r++) { for (int c = 0; c < length; c++) { m.set(r, c, confusionMatrix[r][c]); } } Map<String,Integer> labels = Maps.newHashMap(); for (Map.Entry<String, Integer> ent... | ConfusionMatrix { public Matrix getMatrix() { int length = confusionMatrix.length; Matrix m = new DenseMatrix(length, length); for (int r = 0; r < length; r++) { for (int c = 0; c < length; c++) { m.set(r, c, confusionMatrix[r][c]); } } Map<String,Integer> labels = Maps.newHashMap(); for (Map.Entry<String, Integer> ent... | ConfusionMatrix { public Matrix getMatrix() { int length = confusionMatrix.length; Matrix m = new DenseMatrix(length, length); for (int r = 0; r < length; r++) { for (int c = 0; c < length; c++) { m.set(r, c, confusionMatrix[r][c]); } } Map<String,Integer> labels = Maps.newHashMap(); for (Map.Entry<String, Integer> ent... |
@Test public void testTokenizeDocuments() throws Exception { Configuration configuration = new Configuration(); Path input = new Path(getTestTempDirPath(), "inputDir"); Path output = new Path(getTestTempDirPath(), "outputDir"); FileSystem fs = FileSystem.get(input.toUri(), configuration); String documentId1 = "123"; St... | public static void tokenizeDocuments(Path input, Class<? extends Analyzer> analyzerClass, Path output, Configuration baseConf) throws IOException, InterruptedException, ClassNotFoundException { Configuration conf = new Configuration(baseConf); conf.set("io.serializations", "org.apache.hadoop.io.serializer.JavaSerializa... | DocumentProcessor { public static void tokenizeDocuments(Path input, Class<? extends Analyzer> analyzerClass, Path output, Configuration baseConf) throws IOException, InterruptedException, ClassNotFoundException { Configuration conf = new Configuration(baseConf); conf.set("io.serializations", "org.apache.hadoop.io.seri... | DocumentProcessor { public static void tokenizeDocuments(Path input, Class<? extends Analyzer> analyzerClass, Path output, Configuration baseConf) throws IOException, InterruptedException, ClassNotFoundException { Configuration conf = new Configuration(baseConf); conf.set("io.serializations", "org.apache.hadoop.io.seri... | DocumentProcessor { public static void tokenizeDocuments(Path input, Class<? extends Analyzer> analyzerClass, Path output, Configuration baseConf) throws IOException, InterruptedException, ClassNotFoundException { Configuration conf = new Configuration(baseConf); conf.set("io.serializations", "org.apache.hadoop.io.seri... | DocumentProcessor { public static void tokenizeDocuments(Path input, Class<? extends Analyzer> analyzerClass, Path output, Configuration baseConf) throws IOException, InterruptedException, ClassNotFoundException { Configuration conf = new Configuration(baseConf); conf.set("io.serializations", "org.apache.hadoop.io.seri... |
@Test public void testComparator() { byte[] foo = new byte[1]; foo[0] = (byte) 1; byte[] empty = new byte[0]; GramKey a = new GramKey(new Gram("foo", 1, Gram.Type.HEAD), empty); GramKey b = new GramKey(new Gram("foo", 1, Gram.Type.HEAD), foo); GramKey c = new GramKey(new Gram("foo", 2, Gram.Type.HEAD), empty); GramKey ... | @Override public int compare(WritableComparable a, WritableComparable b) { GramKey gka = (GramKey) a; GramKey gkb = (GramKey) b; return WritableComparator.compareBytes(gka.getBytes(), 0, gka.getPrimaryLength(), gkb.getBytes(), 0, gkb.getPrimaryLength()); } | GramKeyGroupComparator extends WritableComparator implements Serializable { @Override public int compare(WritableComparable a, WritableComparable b) { GramKey gka = (GramKey) a; GramKey gkb = (GramKey) b; return WritableComparator.compareBytes(gka.getBytes(), 0, gka.getPrimaryLength(), gkb.getBytes(), 0, gkb.getPrimary... | GramKeyGroupComparator extends WritableComparator implements Serializable { @Override public int compare(WritableComparable a, WritableComparable b) { GramKey gka = (GramKey) a; GramKey gkb = (GramKey) b; return WritableComparator.compareBytes(gka.getBytes(), 0, gka.getPrimaryLength(), gkb.getBytes(), 0, gkb.getPrimary... | GramKeyGroupComparator extends WritableComparator implements Serializable { @Override public int compare(WritableComparable a, WritableComparable b) { GramKey gka = (GramKey) a; GramKey gkb = (GramKey) b; return WritableComparator.compareBytes(gka.getBytes(), 0, gka.getPrimaryLength(), gkb.getBytes(), 0, gkb.getPrimary... | GramKeyGroupComparator extends WritableComparator implements Serializable { @Override public int compare(WritableComparable a, WritableComparable b) { GramKey gka = (GramKey) a; GramKey gkb = (GramKey) b; return WritableComparator.compareBytes(gka.getBytes(), 0, gka.getPrimaryLength(), gkb.getBytes(), 0, gkb.getPrimary... |
@Test public void testGetNumberOfClusters() throws Exception { List<VectorWritable> points = getPointsWritable(REFERENCE); Path pointsPath = getTestTempDirPath("points"); Configuration conf = new Configuration(); ClusteringTestUtils.writePointsToFile(points, new Path(pointsPath, "file1"), fs, conf); ClusteringTestUtils... | public static int getNumberOfClusters(Path clusterOutputPath, Configuration conf) throws IOException { FileSystem fileSystem = clusterOutputPath.getFileSystem(conf); FileStatus[] clusterFiles = fileSystem.listStatus(clusterOutputPath, PathFilters.finalPartFilter()); int numberOfClusters = 0; Iterator<?> it = new Sequen... | ClusterCountReader { public static int getNumberOfClusters(Path clusterOutputPath, Configuration conf) throws IOException { FileSystem fileSystem = clusterOutputPath.getFileSystem(conf); FileStatus[] clusterFiles = fileSystem.listStatus(clusterOutputPath, PathFilters.finalPartFilter()); int numberOfClusters = 0; Iterat... | ClusterCountReader { public static int getNumberOfClusters(Path clusterOutputPath, Configuration conf) throws IOException { FileSystem fileSystem = clusterOutputPath.getFileSystem(conf); FileStatus[] clusterFiles = fileSystem.listStatus(clusterOutputPath, PathFilters.finalPartFilter()); int numberOfClusters = 0; Iterat... | ClusterCountReader { public static int getNumberOfClusters(Path clusterOutputPath, Configuration conf) throws IOException { FileSystem fileSystem = clusterOutputPath.getFileSystem(conf); FileStatus[] clusterFiles = fileSystem.listStatus(clusterOutputPath, PathFilters.finalPartFilter()); int numberOfClusters = 0; Iterat... | ClusterCountReader { public static int getNumberOfClusters(Path clusterOutputPath, Configuration conf) throws IOException { FileSystem fileSystem = clusterOutputPath.getFileSystem(conf); FileStatus[] clusterFiles = fileSystem.listStatus(clusterOutputPath, PathFilters.finalPartFilter()); int numberOfClusters = 0; Iterat... |
@Test public void testRandomSeedGenerator() throws Exception { List<VectorWritable> points = getPoints(); Job job = new Job(); Configuration conf = job.getConfiguration(); job.setMapOutputValueClass(VectorWritable.class); Path input = getTestTempFilePath("random-input"); Path output = getTestTempDirPath("random-output"... | private RandomSeedGenerator() { } | RandomSeedGenerator { private RandomSeedGenerator() { } } | RandomSeedGenerator { private RandomSeedGenerator() { } private RandomSeedGenerator(); } | RandomSeedGenerator { private RandomSeedGenerator() { } private RandomSeedGenerator(); static Path buildRandom(Configuration conf,
Path input,
Path output,
int k,
DistanceMeasure measure)... | RandomSeedGenerator { private RandomSeedGenerator() { } private RandomSeedGenerator(); static Path buildRandom(Configuration conf,
Path input,
Path output,
int k,
DistanceMeasure measure)... |
@Test public void testSave() throws Exception { Configuration conf = new Configuration(); Writable key = new IntWritable(0); Vector value = new DenseVector(VECTOR); Path path = getTestTempDirPath("output"); VectorCache.save(key, value, path, conf, true, true); SequenceFileValueIterator<VectorWritable> iterator = new Se... | public static void save(Writable key, Vector vector, Path output, Configuration conf, boolean overwritePath, boolean deleteOnExit) throws IOException { FileSystem fs = FileSystem.get(output.toUri(), conf); output = fs.makeQualified(output); if (overwritePath) { HadoopUtil.delete(conf, output); } DistributedCache.setCac... | VectorCache { public static void save(Writable key, Vector vector, Path output, Configuration conf, boolean overwritePath, boolean deleteOnExit) throws IOException { FileSystem fs = FileSystem.get(output.toUri(), conf); output = fs.makeQualified(output); if (overwritePath) { HadoopUtil.delete(conf, output); } Distribut... | VectorCache { public static void save(Writable key, Vector vector, Path output, Configuration conf, boolean overwritePath, boolean deleteOnExit) throws IOException { FileSystem fs = FileSystem.get(output.toUri(), conf); output = fs.makeQualified(output); if (overwritePath) { HadoopUtil.delete(conf, output); } Distribut... | VectorCache { public static void save(Writable key, Vector vector, Path output, Configuration conf, boolean overwritePath, boolean deleteOnExit) throws IOException { FileSystem fs = FileSystem.get(output.toUri(), conf); output = fs.makeQualified(output); if (overwritePath) { HadoopUtil.delete(conf, output); } Distribut... | VectorCache { public static void save(Writable key, Vector vector, Path output, Configuration conf, boolean overwritePath, boolean deleteOnExit) throws IOException { FileSystem fs = FileSystem.get(output.toUri(), conf); output = fs.makeQualified(output); if (overwritePath) { HadoopUtil.delete(conf, output); } Distribut... |
@Test public void testLoad() throws Exception { Configuration conf = new Configuration(); Writable key = new IntWritable(0); Vector value = new DenseVector(VECTOR); Path path = getTestTempDirPath("output"); FileSystem fs = FileSystem.get(path.toUri(), conf); path = fs.makeQualified(path); fs.deleteOnExit(path); HadoopU... | public static Vector load(Configuration conf) throws IOException { URI[] files = DistributedCache.getCacheFiles(conf); if (files == null || files.length < 1) { return null; } log.info("Files are: {}", Arrays.toString(files)); return load(conf, new Path(files[0].getPath())); } | VectorCache { public static Vector load(Configuration conf) throws IOException { URI[] files = DistributedCache.getCacheFiles(conf); if (files == null || files.length < 1) { return null; } log.info("Files are: {}", Arrays.toString(files)); return load(conf, new Path(files[0].getPath())); } } | VectorCache { public static Vector load(Configuration conf) throws IOException { URI[] files = DistributedCache.getCacheFiles(conf); if (files == null || files.length < 1) { return null; } log.info("Files are: {}", Arrays.toString(files)); return load(conf, new Path(files[0].getPath())); } private VectorCache(); } | VectorCache { public static Vector load(Configuration conf) throws IOException { URI[] files = DistributedCache.getCacheFiles(conf); if (files == null || files.length < 1) { return null; } log.info("Files are: {}", Arrays.toString(files)); return load(conf, new Path(files[0].getPath())); } private VectorCache(); stati... | VectorCache { public static Vector load(Configuration conf) throws IOException { URI[] files = DistributedCache.getCacheFiles(conf); if (files == null || files.length < 1) { return null; } log.info("Files are: {}", Arrays.toString(files)); return load(conf, new Path(files[0].getPath())); } private VectorCache(); stati... |
@Test public void testMain() throws Throwable { MahoutDriver.main(new String[] {"canopy", "help"}); } | public static void main(String[] args) throws Throwable { ProgramDriver programDriver = new ProgramDriver(); Properties mainClasses = loadProperties("driver.classes.props"); if (mainClasses == null) { mainClasses = loadProperties("driver.classes.default.props"); } if (mainClasses == null) { throw new IOException("Can't... | MahoutDriver { public static void main(String[] args) throws Throwable { ProgramDriver programDriver = new ProgramDriver(); Properties mainClasses = loadProperties("driver.classes.props"); if (mainClasses == null) { mainClasses = loadProperties("driver.classes.default.props"); } if (mainClasses == null) { throw new IOE... | MahoutDriver { public static void main(String[] args) throws Throwable { ProgramDriver programDriver = new ProgramDriver(); Properties mainClasses = loadProperties("driver.classes.props"); if (mainClasses == null) { mainClasses = loadProperties("driver.classes.default.props"); } if (mainClasses == null) { throw new IOE... | MahoutDriver { public static void main(String[] args) throws Throwable { ProgramDriver programDriver = new ProgramDriver(); Properties mainClasses = loadProperties("driver.classes.props"); if (mainClasses == null) { mainClasses = loadProperties("driver.classes.default.props"); } if (mainClasses == null) { throw new IOE... | MahoutDriver { public static void main(String[] args) throws Throwable { ProgramDriver programDriver = new ProgramDriver(); Properties mainClasses = loadProperties("driver.classes.props"); if (mainClasses == null) { mainClasses = loadProperties("driver.classes.default.props"); } if (mainClasses == null) { throw new IOE... |
@Test public void testSetData() throws IOException { File f = File.createTempFile("matrix", ".m"); f.deleteOnExit(); Random gen = RandomUtils.getRandom(); Matrix m0 = new SparseRowMatrix(10, 21); for (MatrixSlice row : m0) { int len = (int) Math.ceil(-15 * Math.log(1 - gen.nextDouble())); for (int i = 0; i < len; i++) ... | public void setData(File f) throws IOException { List<ByteBuffer> buffers = Lists.newArrayList(); FileChannel input = new FileInputStream(f).getChannel(); buffers.add(input.map(FileChannel.MapMode.READ_ONLY, 0, Math.min(Integer.MAX_VALUE, f.length()))); data.add(buffers.get(0).asIntBuffer()); Preconditions.checkArgumen... | FileBasedSparseBinaryMatrix extends AbstractMatrix { public void setData(File f) throws IOException { List<ByteBuffer> buffers = Lists.newArrayList(); FileChannel input = new FileInputStream(f).getChannel(); buffers.add(input.map(FileChannel.MapMode.READ_ONLY, 0, Math.min(Integer.MAX_VALUE, f.length()))); data.add(buff... | FileBasedSparseBinaryMatrix extends AbstractMatrix { public void setData(File f) throws IOException { List<ByteBuffer> buffers = Lists.newArrayList(); FileChannel input = new FileInputStream(f).getChannel(); buffers.add(input.map(FileChannel.MapMode.READ_ONLY, 0, Math.min(Integer.MAX_VALUE, f.length()))); data.add(buff... | FileBasedSparseBinaryMatrix extends AbstractMatrix { public void setData(File f) throws IOException { List<ByteBuffer> buffers = Lists.newArrayList(); FileChannel input = new FileInputStream(f).getChannel(); buffers.add(input.map(FileChannel.MapMode.READ_ONLY, 0, Math.min(Integer.MAX_VALUE, f.length()))); data.add(buff... | FileBasedSparseBinaryMatrix extends AbstractMatrix { public void setData(File f) throws IOException { List<ByteBuffer> buffers = Lists.newArrayList(); FileChannel input = new FileInputStream(f).getChannel(); buffers.add(input.map(FileChannel.MapMode.READ_ONLY, 0, Math.min(Integer.MAX_VALUE, f.length()))); data.add(buff... |
@Test(expected = IndexException.class) public void testGetUnder() { test.get(-1); } | @Override public double get(int index) { if (index < 0 || index >= size) { throw new IndexException(index, size); } return getQuick(index); } | AbstractVector implements Vector, LengthCachingVector { @Override public double get(int index) { if (index < 0 || index >= size) { throw new IndexException(index, size); } return getQuick(index); } } | AbstractVector implements Vector, LengthCachingVector { @Override public double get(int index) { if (index < 0 || index >= size) { throw new IndexException(index, size); } return getQuick(index); } protected AbstractVector(int size); } | AbstractVector implements Vector, LengthCachingVector { @Override public double get(int index) { if (index < 0 || index >= size) { throw new IndexException(index, size); } return getQuick(index); } protected AbstractVector(int size); @Override double aggregate(DoubleDoubleFunction aggregator, DoubleFunction map); @Ove... | AbstractVector implements Vector, LengthCachingVector { @Override public double get(int index) { if (index < 0 || index >= size) { throw new IndexException(index, size); } return getQuick(index); } protected AbstractVector(int size); @Override double aggregate(DoubleDoubleFunction aggregator, DoubleFunction map); @Ove... |
@Test public void testEigenvalueCheck() throws Exception { int size = 100; Matrix m = randomHierarchicalSymmetricMatrix(size); Vector initialVector = new DenseVector(size); initialVector.assign(1.0 / Math.sqrt(size)); LanczosSolver solver = new LanczosSolver(); int desiredRank = 80; LanczosState state = new LanczosStat... | public void solve(LanczosState state, int desiredRank) { solve(state, desiredRank, false); } | LanczosSolver { public void solve(LanczosState state, int desiredRank) { solve(state, desiredRank, false); } } | LanczosSolver { public void solve(LanczosState state, int desiredRank) { solve(state, desiredRank, false); } } | LanczosSolver { public void solve(LanczosState state, int desiredRank) { solve(state, desiredRank, false); } void solve(LanczosState state,
int desiredRank); void solve(LanczosState state,
int desiredRank,
boolean isSymmetric); } | LanczosSolver { public void solve(LanczosState state, int desiredRank) { solve(state, desiredRank, false); } void solve(LanczosState state,
int desiredRank); void solve(LanczosState state,
int desiredRank,
boolean isSymmetric); static final double SAFE_MAX; } |
@Test public void testSet() { test.set(3, 4.5); for (int i = 0; i < test.size(); i++) { if (i % 2 == 0) { assertEquals("get [" + i + ']', 0.0, test.get(i), EPSILON); } else if (i == 3) { assertEquals("set [" + i + ']', 4.5, test.get(i), EPSILON); } else { assertEquals("set [" + i + ']', values[i/2], test.get(i), EPSILO... | @Override public void set(int index, double value) { if (index < 0 || index >= size) { throw new IndexException(index, size); } setQuick(index, value); } | AbstractVector implements Vector, LengthCachingVector { @Override public void set(int index, double value) { if (index < 0 || index >= size) { throw new IndexException(index, size); } setQuick(index, value); } } | AbstractVector implements Vector, LengthCachingVector { @Override public void set(int index, double value) { if (index < 0 || index >= size) { throw new IndexException(index, size); } setQuick(index, value); } protected AbstractVector(int size); } | AbstractVector implements Vector, LengthCachingVector { @Override public void set(int index, double value) { if (index < 0 || index >= size) { throw new IndexException(index, size); } setQuick(index, value); } protected AbstractVector(int size); @Override double aggregate(DoubleDoubleFunction aggregator, DoubleFunctio... | AbstractVector implements Vector, LengthCachingVector { @Override public void set(int index, double value) { if (index < 0 || index >= size) { throw new IndexException(index, size); } setQuick(index, value); } protected AbstractVector(int size); @Override double aggregate(DoubleDoubleFunction aggregator, DoubleFunctio... |
@Test public void testSize() { assertEquals("size", 3, test.getNumNondefaultElements()); } | @Override public final int size() { return size; } | AbstractVector implements Vector, LengthCachingVector { @Override public final int size() { return size; } } | AbstractVector implements Vector, LengthCachingVector { @Override public final int size() { return size; } protected AbstractVector(int size); } | AbstractVector implements Vector, LengthCachingVector { @Override public final int size() { return size; } protected AbstractVector(int size); @Override double aggregate(DoubleDoubleFunction aggregator, DoubleFunction map); @Override double aggregate(Vector other, DoubleDoubleFunction aggregator, DoubleDoubleFunction ... | AbstractVector implements Vector, LengthCachingVector { @Override public final int size() { return size; } protected AbstractVector(int size); @Override double aggregate(DoubleDoubleFunction aggregator, DoubleFunction map); @Override double aggregate(Vector other, DoubleDoubleFunction aggregator, DoubleDoubleFunction ... |
@Test public void testViewPart() { Vector part = test.viewPart(1, 2); assertEquals("part size", 2, part.getNumNondefaultElements()); for (int i = 0; i < part.size(); i++) { assertEquals("part[" + i + ']', test.get(i+1), part.get(i), EPSILON); } } | @Override public Vector viewPart(int offset, int length) { if (offset < 0) { throw new IndexException(offset, size); } if (offset + length > size) { throw new IndexException(offset + length, size); } return new VectorView(this, offset, length); } | AbstractVector implements Vector, LengthCachingVector { @Override public Vector viewPart(int offset, int length) { if (offset < 0) { throw new IndexException(offset, size); } if (offset + length > size) { throw new IndexException(offset + length, size); } return new VectorView(this, offset, length); } } | AbstractVector implements Vector, LengthCachingVector { @Override public Vector viewPart(int offset, int length) { if (offset < 0) { throw new IndexException(offset, size); } if (offset + length > size) { throw new IndexException(offset + length, size); } return new VectorView(this, offset, length); } protected Abstra... | AbstractVector implements Vector, LengthCachingVector { @Override public Vector viewPart(int offset, int length) { if (offset < 0) { throw new IndexException(offset, size); } if (offset + length > size) { throw new IndexException(offset + length, size); } return new VectorView(this, offset, length); } protected Abstra... | AbstractVector implements Vector, LengthCachingVector { @Override public Vector viewPart(int offset, int length) { if (offset < 0) { throw new IndexException(offset, size); } if (offset + length > size) { throw new IndexException(offset + length, size); } return new VectorView(this, offset, length); } protected Abstra... |
@Test(expected = IndexException.class) public void testViewPartUnder() { test.viewPart(-1, values.length); } | @Override public Vector viewPart(int offset, int length) { if (offset < 0) { throw new IndexException(offset, size); } if (offset + length > size) { throw new IndexException(offset + length, size); } return new VectorView(this, offset, length); } | AbstractVector implements Vector, LengthCachingVector { @Override public Vector viewPart(int offset, int length) { if (offset < 0) { throw new IndexException(offset, size); } if (offset + length > size) { throw new IndexException(offset + length, size); } return new VectorView(this, offset, length); } } | AbstractVector implements Vector, LengthCachingVector { @Override public Vector viewPart(int offset, int length) { if (offset < 0) { throw new IndexException(offset, size); } if (offset + length > size) { throw new IndexException(offset + length, size); } return new VectorView(this, offset, length); } protected Abstra... | AbstractVector implements Vector, LengthCachingVector { @Override public Vector viewPart(int offset, int length) { if (offset < 0) { throw new IndexException(offset, size); } if (offset + length > size) { throw new IndexException(offset + length, size); } return new VectorView(this, offset, length); } protected Abstra... | AbstractVector implements Vector, LengthCachingVector { @Override public Vector viewPart(int offset, int length) { if (offset < 0) { throw new IndexException(offset, size); } if (offset + length > size) { throw new IndexException(offset + length, size); } return new VectorView(this, offset, length); } protected Abstra... |
@Test(expected = IndexException.class) public void testViewPartOver() { test.viewPart(2, 7); } | @Override public Vector viewPart(int offset, int length) { if (offset < 0) { throw new IndexException(offset, size); } if (offset + length > size) { throw new IndexException(offset + length, size); } return new VectorView(this, offset, length); } | AbstractVector implements Vector, LengthCachingVector { @Override public Vector viewPart(int offset, int length) { if (offset < 0) { throw new IndexException(offset, size); } if (offset + length > size) { throw new IndexException(offset + length, size); } return new VectorView(this, offset, length); } } | AbstractVector implements Vector, LengthCachingVector { @Override public Vector viewPart(int offset, int length) { if (offset < 0) { throw new IndexException(offset, size); } if (offset + length > size) { throw new IndexException(offset + length, size); } return new VectorView(this, offset, length); } protected Abstra... | AbstractVector implements Vector, LengthCachingVector { @Override public Vector viewPart(int offset, int length) { if (offset < 0) { throw new IndexException(offset, size); } if (offset + length > size) { throw new IndexException(offset + length, size); } return new VectorView(this, offset, length); } protected Abstra... | AbstractVector implements Vector, LengthCachingVector { @Override public Vector viewPart(int offset, int length) { if (offset < 0) { throw new IndexException(offset, size); } if (offset + length > size) { throw new IndexException(offset + length, size); } return new VectorView(this, offset, length); } protected Abstra... |
@Test public void createMiIi() { Vector f1 = new DenseVector(new double[] { 1, 2, 3 }); Vector f2 = new DenseVector(new double[] { 4, 5, 6 }); DoubleMatrix miIi = JBlasAlternatingLeastSquaresSolver.createMiIi(Arrays.asList(f1, f2), 3); assertEquals(1.0, miIi.get(0, 0), EPSILON); assertEquals(2.0, miIi.get(1, 0), EPSILO... | static DoubleMatrix createMiIi(Iterable<Vector> featureVectors, int numFeatures) { int numRatings = Iterables.size(featureVectors); DoubleMatrix MiIi = new DoubleMatrix(numFeatures, numRatings); int n = 0; for (Vector featureVector : featureVectors) { for (int m = 0; m < numFeatures; m++) { MiIi.put(m, n, featureVector... | JBlasAlternatingLeastSquaresSolver { static DoubleMatrix createMiIi(Iterable<Vector> featureVectors, int numFeatures) { int numRatings = Iterables.size(featureVectors); DoubleMatrix MiIi = new DoubleMatrix(numFeatures, numRatings); int n = 0; for (Vector featureVector : featureVectors) { for (int m = 0; m < numFeatures... | JBlasAlternatingLeastSquaresSolver { static DoubleMatrix createMiIi(Iterable<Vector> featureVectors, int numFeatures) { int numRatings = Iterables.size(featureVectors); DoubleMatrix MiIi = new DoubleMatrix(numFeatures, numRatings); int n = 0; for (Vector featureVector : featureVectors) { for (int m = 0; m < numFeatures... | JBlasAlternatingLeastSquaresSolver { static DoubleMatrix createMiIi(Iterable<Vector> featureVectors, int numFeatures) { int numRatings = Iterables.size(featureVectors); DoubleMatrix MiIi = new DoubleMatrix(numFeatures, numRatings); int n = 0; for (Vector featureVector : featureVectors) { for (int m = 0; m < numFeatures... | JBlasAlternatingLeastSquaresSolver { static DoubleMatrix createMiIi(Iterable<Vector> featureVectors, int numFeatures) { int numRatings = Iterables.size(featureVectors); DoubleMatrix MiIi = new DoubleMatrix(numFeatures, numRatings); int n = 0; for (Vector featureVector : featureVectors) { for (int m = 0; m < numFeatures... |
@Test public void createRiIiMaybeTransposed() { Vector ratings = new SequentialAccessSparseVector(3); ratings.setQuick(1, 1.0); ratings.setQuick(3, 3.0); ratings.setQuick(5, 5.0); DoubleMatrix riIiMaybeTransposed = JBlasAlternatingLeastSquaresSolver.createRiIiMaybeTransposed(ratings); assertEquals(1, riIiMaybeTranspose... | static DoubleMatrix createRiIiMaybeTransposed(Vector ratingVector) { Preconditions.checkArgument(ratingVector.isSequentialAccess()); int numRatings = ratingVector.getNumNondefaultElements(); double[] RiIiMaybeTransposed = new double[numRatings]; Iterator<Vector.Element> ratingsIterator = ratingVector.iterateNonZero(); ... | JBlasAlternatingLeastSquaresSolver { static DoubleMatrix createRiIiMaybeTransposed(Vector ratingVector) { Preconditions.checkArgument(ratingVector.isSequentialAccess()); int numRatings = ratingVector.getNumNondefaultElements(); double[] RiIiMaybeTransposed = new double[numRatings]; Iterator<Vector.Element> ratingsItera... | JBlasAlternatingLeastSquaresSolver { static DoubleMatrix createRiIiMaybeTransposed(Vector ratingVector) { Preconditions.checkArgument(ratingVector.isSequentialAccess()); int numRatings = ratingVector.getNumNondefaultElements(); double[] RiIiMaybeTransposed = new double[numRatings]; Iterator<Vector.Element> ratingsItera... | JBlasAlternatingLeastSquaresSolver { static DoubleMatrix createRiIiMaybeTransposed(Vector ratingVector) { Preconditions.checkArgument(ratingVector.isSequentialAccess()); int numRatings = ratingVector.getNumNondefaultElements(); double[] RiIiMaybeTransposed = new double[numRatings]; Iterator<Vector.Element> ratingsItera... | JBlasAlternatingLeastSquaresSolver { static DoubleMatrix createRiIiMaybeTransposed(Vector ratingVector) { Preconditions.checkArgument(ratingVector.isSequentialAccess()); int numRatings = ratingVector.getNumNondefaultElements(); double[] RiIiMaybeTransposed = new double[numRatings]; Iterator<Vector.Element> ratingsItera... |
@Test public void createRiIiMaybeTransposedExceptionOnNonSequentialVector() { Vector ratings = new RandomAccessSparseVector(3); ratings.setQuick(1, 1.0); ratings.setQuick(3, 3.0); ratings.setQuick(5, 5.0); try { JBlasAlternatingLeastSquaresSolver.createRiIiMaybeTransposed(ratings); fail(); } catch (IllegalArgumentExcep... | static DoubleMatrix createRiIiMaybeTransposed(Vector ratingVector) { Preconditions.checkArgument(ratingVector.isSequentialAccess()); int numRatings = ratingVector.getNumNondefaultElements(); double[] RiIiMaybeTransposed = new double[numRatings]; Iterator<Vector.Element> ratingsIterator = ratingVector.iterateNonZero(); ... | JBlasAlternatingLeastSquaresSolver { static DoubleMatrix createRiIiMaybeTransposed(Vector ratingVector) { Preconditions.checkArgument(ratingVector.isSequentialAccess()); int numRatings = ratingVector.getNumNondefaultElements(); double[] RiIiMaybeTransposed = new double[numRatings]; Iterator<Vector.Element> ratingsItera... | JBlasAlternatingLeastSquaresSolver { static DoubleMatrix createRiIiMaybeTransposed(Vector ratingVector) { Preconditions.checkArgument(ratingVector.isSequentialAccess()); int numRatings = ratingVector.getNumNondefaultElements(); double[] RiIiMaybeTransposed = new double[numRatings]; Iterator<Vector.Element> ratingsItera... | JBlasAlternatingLeastSquaresSolver { static DoubleMatrix createRiIiMaybeTransposed(Vector ratingVector) { Preconditions.checkArgument(ratingVector.isSequentialAccess()); int numRatings = ratingVector.getNumNondefaultElements(); double[] RiIiMaybeTransposed = new double[numRatings]; Iterator<Vector.Element> ratingsItera... | JBlasAlternatingLeastSquaresSolver { static DoubleMatrix createRiIiMaybeTransposed(Vector ratingVector) { Preconditions.checkArgument(ratingVector.isSequentialAccess()); int numRatings = ratingVector.getNumNondefaultElements(); double[] RiIiMaybeTransposed = new double[numRatings]; Iterator<Vector.Element> ratingsItera... |
@Test(expected = IndexException.class) public void testViewPartCardinality() { test.viewPart(1, 8); } | @Override public Vector viewPart(int offset, int length) { if (offset < 0) { throw new IndexException(offset, size); } if (offset + length > size) { throw new IndexException(offset + length, size); } return new VectorView(this, offset, length); } | AbstractVector implements Vector, LengthCachingVector { @Override public Vector viewPart(int offset, int length) { if (offset < 0) { throw new IndexException(offset, size); } if (offset + length > size) { throw new IndexException(offset + length, size); } return new VectorView(this, offset, length); } } | AbstractVector implements Vector, LengthCachingVector { @Override public Vector viewPart(int offset, int length) { if (offset < 0) { throw new IndexException(offset, size); } if (offset + length > size) { throw new IndexException(offset + length, size); } return new VectorView(this, offset, length); } protected Abstra... | AbstractVector implements Vector, LengthCachingVector { @Override public Vector viewPart(int offset, int length) { if (offset < 0) { throw new IndexException(offset, size); } if (offset + length > size) { throw new IndexException(offset + length, size); } return new VectorView(this, offset, length); } protected Abstra... | AbstractVector implements Vector, LengthCachingVector { @Override public Vector viewPart(int offset, int length) { if (offset < 0) { throw new IndexException(offset, size); } if (offset + length > size) { throw new IndexException(offset + length, size); } return new VectorView(this, offset, length); } protected Abstra... |
@Test public void testStart() throws InterruptedException { int port = 8888; int workerIoThreads = 4; int allIdleTimeSeconds = 60; JavaTransportProtocol transportCodec = new JavaTransportProtocol(); ReceiveMessageHandler<Request, Response> receiveMessageHandler = new NettyServerReceiveMessageHandlerTest(); NettyServerT... | @Override public void start() { log.info("The NettyServerTransport will start"); super.start(); serverBootstrap = new ServerBootstrap(); bossGroup = new NioEventLoopGroup(1); if (Epoll.isAvailable()) { workerIoGroup = new EpollEventLoopGroup(workerThreads); } else { workerIoGroup = new NioEventLoopGroup(workerThreads);... | NettyServerTransport extends AbstractServerTransport<SendMsg, ReceMsg> { @Override public void start() { log.info("The NettyServerTransport will start"); super.start(); serverBootstrap = new ServerBootstrap(); bossGroup = new NioEventLoopGroup(1); if (Epoll.isAvailable()) { workerIoGroup = new EpollEventLoopGroup(worke... | NettyServerTransport extends AbstractServerTransport<SendMsg, ReceMsg> { @Override public void start() { log.info("The NettyServerTransport will start"); super.start(); serverBootstrap = new ServerBootstrap(); bossGroup = new NioEventLoopGroup(1); if (Epoll.isAvailable()) { workerIoGroup = new EpollEventLoopGroup(worke... | NettyServerTransport extends AbstractServerTransport<SendMsg, ReceMsg> { @Override public void start() { log.info("The NettyServerTransport will start"); super.start(); serverBootstrap = new ServerBootstrap(); bossGroup = new NioEventLoopGroup(1); if (Epoll.isAvailable()) { workerIoGroup = new EpollEventLoopGroup(worke... | NettyServerTransport extends AbstractServerTransport<SendMsg, ReceMsg> { @Override public void start() { log.info("The NettyServerTransport will start"); super.start(); serverBootstrap = new ServerBootstrap(); bossGroup = new NioEventLoopGroup(1); if (Epoll.isAvailable()) { workerIoGroup = new EpollEventLoopGroup(worke... |
@Test public void invDownloadTxMultiPeer() throws Exception { VersionMessage ver = new VersionMessage(PARAMS, 100); InetSocketAddress address = new InetSocketAddress("127.0.0.1", 4242); Peer peer2 = new Peer(PARAMS, ver, new PeerAddress(PARAMS, address), blockChain); peer2.addWallet(wallet); VersionMessage peerVersion ... | public void addWallet(Wallet wallet) { wallets.add(wallet); } | Peer extends PeerSocketHandler { public void addWallet(Wallet wallet) { wallets.add(wallet); } } | Peer extends PeerSocketHandler { public void addWallet(Wallet wallet) { wallets.add(wallet); } Peer(NetworkParameters params, VersionMessage ver, @Nullable AbstractBlockChain chain, PeerAddress remoteAddress); Peer(NetworkParameters params, VersionMessage ver, PeerAddress remoteAddress,
@Nullable Abstr... | Peer extends PeerSocketHandler { public void addWallet(Wallet wallet) { wallets.add(wallet); } Peer(NetworkParameters params, VersionMessage ver, @Nullable AbstractBlockChain chain, PeerAddress remoteAddress); Peer(NetworkParameters params, VersionMessage ver, PeerAddress remoteAddress,
@Nullable Abstr... | Peer extends PeerSocketHandler { public void addWallet(Wallet wallet) { wallets.add(wallet); } Peer(NetworkParameters params, VersionMessage ver, @Nullable AbstractBlockChain chain, PeerAddress remoteAddress); Peer(NetworkParameters params, VersionMessage ver, PeerAddress remoteAddress,
@Nullable Abstr... |
@Test public void startBlockChainDownload() throws Exception { Block b1 = createFakeBlock(blockStore, Block.BLOCK_HEIGHT_GENESIS).block; blockChain.add(b1); Block b2 = makeSolvedTestBlock(b1); blockChain.add(b2); connect(); fail.set(true); peer.addChainDownloadStartedEventListener(Threading.SAME_THREAD, new ChainDownlo... | public void startBlockChainDownload() { setDownloadData(true); final int blocksLeft = getPeerBlockHeightDifference(); if (blocksLeft >= 0) { for (final ListenerRegistration<ChainDownloadStartedEventListener> registration : chainDownloadStartedEventListeners) { registration.executor.execute(new Runnable() { @Override pu... | Peer extends PeerSocketHandler { public void startBlockChainDownload() { setDownloadData(true); final int blocksLeft = getPeerBlockHeightDifference(); if (blocksLeft >= 0) { for (final ListenerRegistration<ChainDownloadStartedEventListener> registration : chainDownloadStartedEventListeners) { registration.executor.exec... | Peer extends PeerSocketHandler { public void startBlockChainDownload() { setDownloadData(true); final int blocksLeft = getPeerBlockHeightDifference(); if (blocksLeft >= 0) { for (final ListenerRegistration<ChainDownloadStartedEventListener> registration : chainDownloadStartedEventListeners) { registration.executor.exec... | Peer extends PeerSocketHandler { public void startBlockChainDownload() { setDownloadData(true); final int blocksLeft = getPeerBlockHeightDifference(); if (blocksLeft >= 0) { for (final ListenerRegistration<ChainDownloadStartedEventListener> registration : chainDownloadStartedEventListeners) { registration.executor.exec... | Peer extends PeerSocketHandler { public void startBlockChainDownload() { setDownloadData(true); final int blocksLeft = getPeerBlockHeightDifference(); if (blocksLeft >= 0) { for (final ListenerRegistration<ChainDownloadStartedEventListener> registration : chainDownloadStartedEventListeners) { registration.executor.exec... |
@Test public void timeLockedTransactionNew() throws Exception { connectWithVersion(70001, VersionMessage.NODE_NETWORK | VersionMessage.NODE_BITCOIN_CASH); Wallet wallet = new Wallet(PARAMS); ECKey key = wallet.freshReceiveKey(); peer.addWallet(wallet); final Transaction[] vtx = new Transaction[1]; wallet.addCoinsReceiv... | public void addWallet(Wallet wallet) { wallets.add(wallet); } | Peer extends PeerSocketHandler { public void addWallet(Wallet wallet) { wallets.add(wallet); } } | Peer extends PeerSocketHandler { public void addWallet(Wallet wallet) { wallets.add(wallet); } Peer(NetworkParameters params, VersionMessage ver, @Nullable AbstractBlockChain chain, PeerAddress remoteAddress); Peer(NetworkParameters params, VersionMessage ver, PeerAddress remoteAddress,
@Nullable Abstr... | Peer extends PeerSocketHandler { public void addWallet(Wallet wallet) { wallets.add(wallet); } Peer(NetworkParameters params, VersionMessage ver, @Nullable AbstractBlockChain chain, PeerAddress remoteAddress); Peer(NetworkParameters params, VersionMessage ver, PeerAddress remoteAddress,
@Nullable Abstr... | Peer extends PeerSocketHandler { public void addWallet(Wallet wallet) { wallets.add(wallet); } Peer(NetworkParameters params, VersionMessage ver, @Nullable AbstractBlockChain chain, PeerAddress remoteAddress); Peer(NetworkParameters params, VersionMessage ver, PeerAddress remoteAddress,
@Nullable Abstr... |
@Test public void getUTXOs() throws Exception { connectWithVersion(GetUTXOsMessage.MIN_PROTOCOL_VERSION, VersionMessage.NODE_NETWORK | VersionMessage.NODE_GETUTXOS | VersionMessage.NODE_BITCOIN_CASH); TransactionOutPoint op1 = new TransactionOutPoint(PARAMS, 1, Sha256Hash.of("foo".getBytes())); TransactionOutPoint op2 ... | public ListenableFuture<UTXOsMessage> getUTXOs(List<TransactionOutPoint> outPoints) { return getUTXOs(outPoints, true); } | Peer extends PeerSocketHandler { public ListenableFuture<UTXOsMessage> getUTXOs(List<TransactionOutPoint> outPoints) { return getUTXOs(outPoints, true); } } | Peer extends PeerSocketHandler { public ListenableFuture<UTXOsMessage> getUTXOs(List<TransactionOutPoint> outPoints) { return getUTXOs(outPoints, true); } Peer(NetworkParameters params, VersionMessage ver, @Nullable AbstractBlockChain chain, PeerAddress remoteAddress); Peer(NetworkParameters params, VersionMessage ver... | Peer extends PeerSocketHandler { public ListenableFuture<UTXOsMessage> getUTXOs(List<TransactionOutPoint> outPoints) { return getUTXOs(outPoints, true); } Peer(NetworkParameters params, VersionMessage ver, @Nullable AbstractBlockChain chain, PeerAddress remoteAddress); Peer(NetworkParameters params, VersionMessage ver... | Peer extends PeerSocketHandler { public ListenableFuture<UTXOsMessage> getUTXOs(List<TransactionOutPoint> outPoints) { return getUTXOs(outPoints, true); } Peer(NetworkParameters params, VersionMessage ver, @Nullable AbstractBlockChain chain, PeerAddress remoteAddress); Peer(NetworkParameters params, VersionMessage ver... |
@Test public void waitForPeersOfVersion() throws Exception { final int baseVer = peerGroup.getMinRequiredProtocolVersion() + 3000; final int newVer = baseVer + 1000; ListenableFuture<List<Peer>> future = peerGroup.waitForPeersOfVersion(2, newVer); VersionMessage ver1 = new VersionMessage(PARAMS, 10); ver1.clientVersion... | public ListenableFuture<List<Peer>> waitForPeersOfVersion(final int numPeers, final long protocolVersion) { List<Peer> foundPeers = findPeersOfAtLeastVersion(protocolVersion); if (foundPeers.size() >= numPeers) { return Futures.immediateFuture(foundPeers); } final SettableFuture<List<Peer>> future = SettableFuture.crea... | PeerGroup implements TransactionBroadcaster { public ListenableFuture<List<Peer>> waitForPeersOfVersion(final int numPeers, final long protocolVersion) { List<Peer> foundPeers = findPeersOfAtLeastVersion(protocolVersion); if (foundPeers.size() >= numPeers) { return Futures.immediateFuture(foundPeers); } final SettableF... | PeerGroup implements TransactionBroadcaster { public ListenableFuture<List<Peer>> waitForPeersOfVersion(final int numPeers, final long protocolVersion) { List<Peer> foundPeers = findPeersOfAtLeastVersion(protocolVersion); if (foundPeers.size() >= numPeers) { return Futures.immediateFuture(foundPeers); } final SettableF... | PeerGroup implements TransactionBroadcaster { public ListenableFuture<List<Peer>> waitForPeersOfVersion(final int numPeers, final long protocolVersion) { List<Peer> foundPeers = findPeersOfAtLeastVersion(protocolVersion); if (foundPeers.size() >= numPeers) { return Futures.immediateFuture(foundPeers); } final SettableF... | PeerGroup implements TransactionBroadcaster { public ListenableFuture<List<Peer>> waitForPeersOfVersion(final int numPeers, final long protocolVersion) { List<Peer> foundPeers = findPeersOfAtLeastVersion(protocolVersion); if (foundPeers.size() >= numPeers) { return Futures.immediateFuture(foundPeers); } final SettableF... |
@Test public void badDifficulty() throws Exception { assertTrue(testNetChain.add(getBlock1())); Block b2 = getBlock2(); assertTrue(testNetChain.add(b2)); Block bad = new Block(testNet, Block.BLOCK_VERSION_GENESIS); bad.setMerkleRoot(Sha256Hash.wrap("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); b... | @Override public boolean add(FilteredBlock block) throws VerificationException, PrunedException { boolean success = super.add(block); if (success) { trackFilteredTransactions(block.getTransactionCount()); } return success; } | BlockChain extends AbstractBlockChain { @Override public boolean add(FilteredBlock block) throws VerificationException, PrunedException { boolean success = super.add(block); if (success) { trackFilteredTransactions(block.getTransactionCount()); } return success; } } | BlockChain extends AbstractBlockChain { @Override public boolean add(FilteredBlock block) throws VerificationException, PrunedException { boolean success = super.add(block); if (success) { trackFilteredTransactions(block.getTransactionCount()); } return success; } BlockChain(Context context, Wallet wallet, BlockStore b... | BlockChain extends AbstractBlockChain { @Override public boolean add(FilteredBlock block) throws VerificationException, PrunedException { boolean success = super.add(block); if (success) { trackFilteredTransactions(block.getTransactionCount()); } return success; } BlockChain(Context context, Wallet wallet, BlockStore b... | BlockChain extends AbstractBlockChain { @Override public boolean add(FilteredBlock block) throws VerificationException, PrunedException { boolean success = super.add(block); if (success) { trackFilteredTransactions(block.getTransactionCount()); } return success; } BlockChain(Context context, Wallet wallet, BlockStore b... |
@Test public void testToStringWhenThereAreZeroInputs() { Transaction tx = new Transaction(PARAMS); assertEquals(tx.toString().contains("No inputs!"), true); } | @Override public String toString() { return toString(null); } | Transaction extends ChildMessage { @Override public String toString() { return toString(null); } } | Transaction extends ChildMessage { @Override public String toString() { return toString(null); } Transaction(NetworkParameters params); Transaction(NetworkParameters params, byte[] payloadBytes); Transaction(NetworkParameters params, byte[] payload, int offset); Transaction(NetworkParameters params, byte[] payload, ... | Transaction extends ChildMessage { @Override public String toString() { return toString(null); } Transaction(NetworkParameters params); Transaction(NetworkParameters params, byte[] payloadBytes); Transaction(NetworkParameters params, byte[] payload, int offset); Transaction(NetworkParameters params, byte[] payload, ... | Transaction extends ChildMessage { @Override public String toString() { return toString(null); } Transaction(NetworkParameters params); Transaction(NetworkParameters params, byte[] payloadBytes); Transaction(NetworkParameters params, byte[] payload, int offset); Transaction(NetworkParameters params, byte[] payload, ... |
@Test public void testCoinbaseHeightCheck() throws VerificationException { final byte[] transactionBytes = HEX.decode("01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4803e09304062f503253482f0403c86d53087ceca141295a00002e522cfabe6d6d7561cf262313da1144026c8f7a43e3899c44f6145f39a36507d36... | public void checkCoinBaseHeight(final int height) throws VerificationException { checkArgument(height >= Block.BLOCK_HEIGHT_GENESIS); checkState(isCoinBase()); final TransactionInput in = this.getInputs().get(0); final ScriptBuilder builder = new ScriptBuilder(); builder.number(height); final byte[] expected = builder.... | Transaction extends ChildMessage { public void checkCoinBaseHeight(final int height) throws VerificationException { checkArgument(height >= Block.BLOCK_HEIGHT_GENESIS); checkState(isCoinBase()); final TransactionInput in = this.getInputs().get(0); final ScriptBuilder builder = new ScriptBuilder(); builder.number(height... | Transaction extends ChildMessage { public void checkCoinBaseHeight(final int height) throws VerificationException { checkArgument(height >= Block.BLOCK_HEIGHT_GENESIS); checkState(isCoinBase()); final TransactionInput in = this.getInputs().get(0); final ScriptBuilder builder = new ScriptBuilder(); builder.number(height... | Transaction extends ChildMessage { public void checkCoinBaseHeight(final int height) throws VerificationException { checkArgument(height >= Block.BLOCK_HEIGHT_GENESIS); checkState(isCoinBase()); final TransactionInput in = this.getInputs().get(0); final ScriptBuilder builder = new ScriptBuilder(); builder.number(height... | Transaction extends ChildMessage { public void checkCoinBaseHeight(final int height) throws VerificationException { checkArgument(height >= Block.BLOCK_HEIGHT_GENESIS); checkState(isCoinBase()); final TransactionInput in = this.getInputs().get(0); final ScriptBuilder builder = new ScriptBuilder(); builder.number(height... |
@Test public void testCoinbaseHeightCheckWithDamagedScript() throws VerificationException { final byte[] transactionBytes = HEX.decode( "010000000100000000000000000000000000000000000000000000000000000000" + "00000000ffffffff3b03ae6c0300044bd7031a0400000000522cfabe6d6d0000" + "0000000000b7b8bf0100000068692066726f6d20706... | public void checkCoinBaseHeight(final int height) throws VerificationException { checkArgument(height >= Block.BLOCK_HEIGHT_GENESIS); checkState(isCoinBase()); final TransactionInput in = this.getInputs().get(0); final ScriptBuilder builder = new ScriptBuilder(); builder.number(height); final byte[] expected = builder.... | Transaction extends ChildMessage { public void checkCoinBaseHeight(final int height) throws VerificationException { checkArgument(height >= Block.BLOCK_HEIGHT_GENESIS); checkState(isCoinBase()); final TransactionInput in = this.getInputs().get(0); final ScriptBuilder builder = new ScriptBuilder(); builder.number(height... | Transaction extends ChildMessage { public void checkCoinBaseHeight(final int height) throws VerificationException { checkArgument(height >= Block.BLOCK_HEIGHT_GENESIS); checkState(isCoinBase()); final TransactionInput in = this.getInputs().get(0); final ScriptBuilder builder = new ScriptBuilder(); builder.number(height... | Transaction extends ChildMessage { public void checkCoinBaseHeight(final int height) throws VerificationException { checkArgument(height >= Block.BLOCK_HEIGHT_GENESIS); checkState(isCoinBase()); final TransactionInput in = this.getInputs().get(0); final ScriptBuilder builder = new ScriptBuilder(); builder.number(height... | Transaction extends ChildMessage { public void checkCoinBaseHeight(final int height) throws VerificationException { checkArgument(height >= Block.BLOCK_HEIGHT_GENESIS); checkState(isCoinBase()); final TransactionInput in = this.getInputs().get(0); final ScriptBuilder builder = new ScriptBuilder(); builder.number(height... |
@Test public void testHashForSignature() { MainNetParams MAIN = new MainNetParams(); String dumpedPrivateKey = "KyYyHLChvJKrM4kxCEpdmqR2usQoET2V1JbexZjaxV36wytPw7v1"; DumpedPrivateKey dumpedPrivateKey1 = DumpedPrivateKey.fromBase58(MAIN, dumpedPrivateKey); ECKey key = dumpedPrivateKey1.getKey(); String txData = "020000... | public Sha256Hash hashForSignature(int inputIndex, byte[] redeemScript, SigHash type, boolean anyoneCanPay) { byte sigHashType = (byte) TransactionSignature.calcSigHashValue(type, anyoneCanPay); return hashForSignature(inputIndex, redeemScript, sigHashType); } | Transaction extends ChildMessage { public Sha256Hash hashForSignature(int inputIndex, byte[] redeemScript, SigHash type, boolean anyoneCanPay) { byte sigHashType = (byte) TransactionSignature.calcSigHashValue(type, anyoneCanPay); return hashForSignature(inputIndex, redeemScript, sigHashType); } } | Transaction extends ChildMessage { public Sha256Hash hashForSignature(int inputIndex, byte[] redeemScript, SigHash type, boolean anyoneCanPay) { byte sigHashType = (byte) TransactionSignature.calcSigHashValue(type, anyoneCanPay); return hashForSignature(inputIndex, redeemScript, sigHashType); } Transaction(NetworkParam... | Transaction extends ChildMessage { public Sha256Hash hashForSignature(int inputIndex, byte[] redeemScript, SigHash type, boolean anyoneCanPay) { byte sigHashType = (byte) TransactionSignature.calcSigHashValue(type, anyoneCanPay); return hashForSignature(inputIndex, redeemScript, sigHashType); } Transaction(NetworkParam... | Transaction extends ChildMessage { public Sha256Hash hashForSignature(int inputIndex, byte[] redeemScript, SigHash type, boolean anyoneCanPay) { byte sigHashType = (byte) TransactionSignature.calcSigHashValue(type, anyoneCanPay); return hashForSignature(inputIndex, redeemScript, sigHashType); } Transaction(NetworkParam... |
@Test public void testReverseBytes() { assertArrayEquals(new byte[]{1, 2, 3, 4, 5}, Utils.reverseBytes(new byte[]{5, 4, 3, 2, 1})); } | public static byte[] reverseBytes(byte[] bytes) { byte[] buf = new byte[bytes.length]; for (int i = 0; i < bytes.length; i++) buf[i] = bytes[bytes.length - 1 - i]; return buf; } | Utils { public static byte[] reverseBytes(byte[] bytes) { byte[] buf = new byte[bytes.length]; for (int i = 0; i < bytes.length; i++) buf[i] = bytes[bytes.length - 1 - i]; return buf; } } | Utils { public static byte[] reverseBytes(byte[] bytes) { byte[] buf = new byte[bytes.length]; for (int i = 0; i < bytes.length; i++) buf[i] = bytes[bytes.length - 1 - i]; return buf; } } | Utils { public static byte[] reverseBytes(byte[] bytes) { byte[] buf = new byte[bytes.length]; for (int i = 0; i < bytes.length; i++) buf[i] = bytes[bytes.length - 1 - i]; return buf; } static byte[] bigIntegerToBytes(BigInteger b, int numBytes); static void uint32ToByteArrayBE(long val, byte[] out, int offset); stati... | Utils { public static byte[] reverseBytes(byte[] bytes) { byte[] buf = new byte[bytes.length]; for (int i = 0; i < bytes.length; i++) buf[i] = bytes[bytes.length - 1 - i]; return buf; } static byte[] bigIntegerToBytes(BigInteger b, int numBytes); static void uint32ToByteArrayBE(long val, byte[] out, int offset); stati... |
@Test public void testReverseDwordBytes() { assertArrayEquals(new byte[]{1, 2, 3, 4, 5, 6, 7, 8}, Utils.reverseDwordBytes(new byte[]{4, 3, 2, 1, 8, 7, 6, 5}, -1)); assertArrayEquals(new byte[]{1, 2, 3, 4}, Utils.reverseDwordBytes(new byte[]{4, 3, 2, 1, 8, 7, 6, 5}, 4)); assertArrayEquals(new byte[0], Utils.reverseDword... | public static byte[] reverseDwordBytes(byte[] bytes, int trimLength) { checkArgument(bytes.length % 4 == 0); checkArgument(trimLength < 0 || trimLength % 4 == 0); byte[] rev = new byte[trimLength >= 0 && bytes.length > trimLength ? trimLength : bytes.length]; for (int i = 0; i < rev.length; i += 4) { System.arraycopy(b... | Utils { public static byte[] reverseDwordBytes(byte[] bytes, int trimLength) { checkArgument(bytes.length % 4 == 0); checkArgument(trimLength < 0 || trimLength % 4 == 0); byte[] rev = new byte[trimLength >= 0 && bytes.length > trimLength ? trimLength : bytes.length]; for (int i = 0; i < rev.length; i += 4) { System.arr... | Utils { public static byte[] reverseDwordBytes(byte[] bytes, int trimLength) { checkArgument(bytes.length % 4 == 0); checkArgument(trimLength < 0 || trimLength % 4 == 0); byte[] rev = new byte[trimLength >= 0 && bytes.length > trimLength ? trimLength : bytes.length]; for (int i = 0; i < rev.length; i += 4) { System.arr... | Utils { public static byte[] reverseDwordBytes(byte[] bytes, int trimLength) { checkArgument(bytes.length % 4 == 0); checkArgument(trimLength < 0 || trimLength % 4 == 0); byte[] rev = new byte[trimLength >= 0 && bytes.length > trimLength ? trimLength : bytes.length]; for (int i = 0; i < rev.length; i += 4) { System.arr... | Utils { public static byte[] reverseDwordBytes(byte[] bytes, int trimLength) { checkArgument(bytes.length % 4 == 0); checkArgument(trimLength < 0 || trimLength % 4 == 0); byte[] rev = new byte[trimLength >= 0 && bytes.length > trimLength ? trimLength : bytes.length]; for (int i = 0; i < rev.length; i += 4) { System.arr... |
@Test public void testConvertToBitcoinURI() throws Exception { Address goodAddress = Address.fromBase58(MAINNET, MAINNET_GOOD_ADDRESS); assertEquals("bitcoincash:" + MAINNET_GOOD_ADDRESS + "?amount=12.34&label=Hello&message=AMessage", BitcoinURI.convertToBitcoinURI(goodAddress, parseCoin("12.34"), "Hello", "AMessage"))... | public static String convertToBitcoinURI(Address address, Coin amount, String label, String message) { return convertToBitcoinURI(address.getParameters(), address.toString(), amount, label, message); } | BitcoinURI { public static String convertToBitcoinURI(Address address, Coin amount, String label, String message) { return convertToBitcoinURI(address.getParameters(), address.toString(), amount, label, message); } } | BitcoinURI { public static String convertToBitcoinURI(Address address, Coin amount, String label, String message) { return convertToBitcoinURI(address.getParameters(), address.toString(), amount, label, message); } BitcoinURI(String uri); BitcoinURI(@Nullable NetworkParameters params, String input); } | BitcoinURI { public static String convertToBitcoinURI(Address address, Coin amount, String label, String message) { return convertToBitcoinURI(address.getParameters(), address.toString(), amount, label, message); } BitcoinURI(String uri); BitcoinURI(@Nullable NetworkParameters params, String input); @Nullable Address ... | BitcoinURI { public static String convertToBitcoinURI(Address address, Coin amount, String label, String message) { return convertToBitcoinURI(address.getParameters(), address.toString(), amount, label, message); } BitcoinURI(String uri); BitcoinURI(@Nullable NetworkParameters params, String input); @Nullable Address ... |
@Test public void testMaxOfMostFreq() throws Exception { assertEquals(0, Utils.maxOfMostFreq()); assertEquals(0, Utils.maxOfMostFreq(0, 0, 1)); assertEquals(2, Utils.maxOfMostFreq(1, 1, 2, 2)); assertEquals(1, Utils.maxOfMostFreq(1, 1, 2, 2, 1)); assertEquals(-1, Utils.maxOfMostFreq(-1, -1, 2, 2, -1)); } | public static int maxOfMostFreq(int... items) { ArrayList<Integer> list = new ArrayList<Integer>(items.length); for (int item : items) list.add(item); return maxOfMostFreq(list); } | Utils { public static int maxOfMostFreq(int... items) { ArrayList<Integer> list = new ArrayList<Integer>(items.length); for (int item : items) list.add(item); return maxOfMostFreq(list); } } | Utils { public static int maxOfMostFreq(int... items) { ArrayList<Integer> list = new ArrayList<Integer>(items.length); for (int item : items) list.add(item); return maxOfMostFreq(list); } } | Utils { public static int maxOfMostFreq(int... items) { ArrayList<Integer> list = new ArrayList<Integer>(items.length); for (int item : items) list.add(item); return maxOfMostFreq(list); } static byte[] bigIntegerToBytes(BigInteger b, int numBytes); static void uint32ToByteArrayBE(long val, byte[] out, int offset); st... | Utils { public static int maxOfMostFreq(int... items) { ArrayList<Integer> list = new ArrayList<Integer>(items.length); for (int item : items) list.add(item); return maxOfMostFreq(list); } static byte[] bigIntegerToBytes(BigInteger b, int numBytes); static void uint32ToByteArrayBE(long val, byte[] out, int offset); st... |
@Test public void dateTimeFormat() { assertEquals("2014-11-16T10:54:33Z", Utils.dateTimeFormat(1416135273781L)); assertEquals("2014-11-16T10:54:33Z", Utils.dateTimeFormat(new Date(1416135273781L))); } | public static String dateTimeFormat(Date dateTime) { DateFormat iso8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US); iso8601.setTimeZone(UTC); return iso8601.format(dateTime); } | Utils { public static String dateTimeFormat(Date dateTime) { DateFormat iso8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US); iso8601.setTimeZone(UTC); return iso8601.format(dateTime); } } | Utils { public static String dateTimeFormat(Date dateTime) { DateFormat iso8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US); iso8601.setTimeZone(UTC); return iso8601.format(dateTime); } } | Utils { public static String dateTimeFormat(Date dateTime) { DateFormat iso8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US); iso8601.setTimeZone(UTC); return iso8601.format(dateTime); } static byte[] bigIntegerToBytes(BigInteger b, int numBytes); static void uint32ToByteArrayBE(long val, byte[] out, ... | Utils { public static String dateTimeFormat(Date dateTime) { DateFormat iso8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US); iso8601.setTimeZone(UTC); return iso8601.format(dateTime); } static byte[] bigIntegerToBytes(BigInteger b, int numBytes); static void uint32ToByteArrayBE(long val, byte[] out, ... |
@Test public void testParseCoin() { assertEquals(CENT, parseCoin("0.01")); assertEquals(CENT, parseCoin("1E-2")); assertEquals(COIN.add(CENT), parseCoin("1.01")); assertEquals(COIN.negate(), parseCoin("-1")); try { parseCoin("2E-20"); org.junit.Assert.fail("should not have accepted fractional satoshis"); } catch (Illeg... | public static Coin parseCoin(final String str) { try { long satoshis = new BigDecimal(str).movePointRight(SMALLEST_UNIT_EXPONENT).toBigIntegerExact().longValue(); return Coin.valueOf(satoshis); } catch (ArithmeticException e) { throw new IllegalArgumentException(e); } } | Coin implements Monetary, Comparable<Coin>, Serializable { public static Coin parseCoin(final String str) { try { long satoshis = new BigDecimal(str).movePointRight(SMALLEST_UNIT_EXPONENT).toBigIntegerExact().longValue(); return Coin.valueOf(satoshis); } catch (ArithmeticException e) { throw new IllegalArgumentExceptio... | Coin implements Monetary, Comparable<Coin>, Serializable { public static Coin parseCoin(final String str) { try { long satoshis = new BigDecimal(str).movePointRight(SMALLEST_UNIT_EXPONENT).toBigIntegerExact().longValue(); return Coin.valueOf(satoshis); } catch (ArithmeticException e) { throw new IllegalArgumentExceptio... | Coin implements Monetary, Comparable<Coin>, Serializable { public static Coin parseCoin(final String str) { try { long satoshis = new BigDecimal(str).movePointRight(SMALLEST_UNIT_EXPONENT).toBigIntegerExact().longValue(); return Coin.valueOf(satoshis); } catch (ArithmeticException e) { throw new IllegalArgumentExceptio... | Coin implements Monetary, Comparable<Coin>, Serializable { public static Coin parseCoin(final String str) { try { long satoshis = new BigDecimal(str).movePointRight(SMALLEST_UNIT_EXPONENT).toBigIntegerExact().longValue(); return Coin.valueOf(satoshis); } catch (ArithmeticException e) { throw new IllegalArgumentExceptio... |
@Test public void testValueOf() { assertEquals(CENT, valueOf(0, 1)); assertEquals(SATOSHI, valueOf(1)); assertEquals(NEGATIVE_SATOSHI, valueOf(-1)); assertEquals(MAX_MONEY, valueOf(MAX_MONEY.value)); assertEquals(MAX_MONEY.negate(), valueOf(MAX_MONEY.value * -1)); valueOf(MAX_MONEY.value + 1); valueOf((MAX_MONEY.value ... | public static Coin valueOf(final long satoshis) { return new Coin(satoshis); } | Coin implements Monetary, Comparable<Coin>, Serializable { public static Coin valueOf(final long satoshis) { return new Coin(satoshis); } } | Coin implements Monetary, Comparable<Coin>, Serializable { public static Coin valueOf(final long satoshis) { return new Coin(satoshis); } private Coin(final long satoshis); } | Coin implements Monetary, Comparable<Coin>, Serializable { public static Coin valueOf(final long satoshis) { return new Coin(satoshis); } private Coin(final long satoshis); static Coin valueOf(final long satoshis); @Override int smallestUnitExponent(); @Override long getValue(); static Coin valueOf(final int coins, fi... | Coin implements Monetary, Comparable<Coin>, Serializable { public static Coin valueOf(final long satoshis) { return new Coin(satoshis); } private Coin(final long satoshis); static Coin valueOf(final long satoshis); @Override int smallestUnitExponent(); @Override long getValue(); static Coin valueOf(final int coins, fi... |
@Test public void testToFriendlyString() { assertEquals("1.00 BCH", COIN.toFriendlyString()); assertEquals("1.23 BCH", valueOf(1, 23).toFriendlyString()); assertEquals("0.001 BCH", COIN.divide(1000).toFriendlyString()); assertEquals("-1.23 BCH", valueOf(1, 23).negate().toFriendlyString()); } | public String toFriendlyString() { return FRIENDLY_FORMAT.format(this).toString(); } | Coin implements Monetary, Comparable<Coin>, Serializable { public String toFriendlyString() { return FRIENDLY_FORMAT.format(this).toString(); } } | Coin implements Monetary, Comparable<Coin>, Serializable { public String toFriendlyString() { return FRIENDLY_FORMAT.format(this).toString(); } private Coin(final long satoshis); } | Coin implements Monetary, Comparable<Coin>, Serializable { public String toFriendlyString() { return FRIENDLY_FORMAT.format(this).toString(); } private Coin(final long satoshis); static Coin valueOf(final long satoshis); @Override int smallestUnitExponent(); @Override long getValue(); static Coin valueOf(final int coi... | Coin implements Monetary, Comparable<Coin>, Serializable { public String toFriendlyString() { return FRIENDLY_FORMAT.format(this).toString(); } private Coin(final long satoshis); static Coin valueOf(final long satoshis); @Override int smallestUnitExponent(); @Override long getValue(); static Coin valueOf(final int coi... |
@Test public void testToPlainString() { assertEquals("0.0015", Coin.valueOf(150000).toPlainString()); assertEquals("1.23", parseCoin("1.23").toPlainString()); assertEquals("0.1", parseCoin("0.1").toPlainString()); assertEquals("1.1", parseCoin("1.1").toPlainString()); assertEquals("21.12", parseCoin("21.12").toPlainStr... | public String toPlainString() { return PLAIN_FORMAT.format(this).toString(); } | Coin implements Monetary, Comparable<Coin>, Serializable { public String toPlainString() { return PLAIN_FORMAT.format(this).toString(); } } | Coin implements Monetary, Comparable<Coin>, Serializable { public String toPlainString() { return PLAIN_FORMAT.format(this).toString(); } private Coin(final long satoshis); } | Coin implements Monetary, Comparable<Coin>, Serializable { public String toPlainString() { return PLAIN_FORMAT.format(this).toString(); } private Coin(final long satoshis); static Coin valueOf(final long satoshis); @Override int smallestUnitExponent(); @Override long getValue(); static Coin valueOf(final int coins, fi... | Coin implements Monetary, Comparable<Coin>, Serializable { public String toPlainString() { return PLAIN_FORMAT.format(this).toString(); } private Coin(final long satoshis); static Coin valueOf(final long satoshis); @Override int smallestUnitExponent(); @Override long getValue(); static Coin valueOf(final int coins, fi... |
@Test public void coinAgeOrdering() throws Exception { Transaction t1 = checkNotNull(sendMoneyToWallet(AbstractBlockChain.NewBlockType.BEST_CHAIN, COIN)); wallet.notifyNewBestBlock(FakeTxBuilder.createFakeBlock(blockStore, Block.BLOCK_HEIGHT_GENESIS).storedBlock); final Coin TWO_COINS = COIN.multiply(2); Transaction t2... | @VisibleForTesting static void sortOutputs(ArrayList<TransactionOutput> outputs) { Collections.sort(outputs, new Comparator<TransactionOutput>() { @Override public int compare(TransactionOutput a, TransactionOutput b) { int depth1 = a.getParentTransactionDepthInBlocks(); int depth2 = b.getParentTransactionDepthInBlocks... | DefaultCoinSelector implements CoinSelector { @VisibleForTesting static void sortOutputs(ArrayList<TransactionOutput> outputs) { Collections.sort(outputs, new Comparator<TransactionOutput>() { @Override public int compare(TransactionOutput a, TransactionOutput b) { int depth1 = a.getParentTransactionDepthInBlocks(); in... | DefaultCoinSelector implements CoinSelector { @VisibleForTesting static void sortOutputs(ArrayList<TransactionOutput> outputs) { Collections.sort(outputs, new Comparator<TransactionOutput>() { @Override public int compare(TransactionOutput a, TransactionOutput b) { int depth1 = a.getParentTransactionDepthInBlocks(); in... | DefaultCoinSelector implements CoinSelector { @VisibleForTesting static void sortOutputs(ArrayList<TransactionOutput> outputs) { Collections.sort(outputs, new Comparator<TransactionOutput>() { @Override public int compare(TransactionOutput a, TransactionOutput b) { int depth1 = a.getParentTransactionDepthInBlocks(); in... | DefaultCoinSelector implements CoinSelector { @VisibleForTesting static void sortOutputs(ArrayList<TransactionOutput> outputs) { Collections.sort(outputs, new Comparator<TransactionOutput>() { @Override public int compare(TransactionOutput a, TransactionOutput b) { int depth1 = a.getParentTransactionDepthInBlocks(); in... |
@Test public void identicalInputs() throws Exception { Transaction t = new Transaction(PARAMS); java.util.List<TransactionOutput> outputs = Arrays.asList( new TransactionOutput(PARAMS, t, Coin.valueOf(30302787), myAddress), new TransactionOutput(PARAMS, t, Coin.valueOf(30302787), myAddress), new TransactionOutput(PARAM... | @Override public CoinSelection select(Coin target, List<TransactionOutput> candidates) { ArrayList<TransactionOutput> selected = new ArrayList<TransactionOutput>(); ArrayList<TransactionOutput> sortedOutputs = new ArrayList<TransactionOutput>(candidates); if (!target.equals(NetworkParameters.MAX_MONEY)) { sortOutputs(s... | DefaultCoinSelector implements CoinSelector { @Override public CoinSelection select(Coin target, List<TransactionOutput> candidates) { ArrayList<TransactionOutput> selected = new ArrayList<TransactionOutput>(); ArrayList<TransactionOutput> sortedOutputs = new ArrayList<TransactionOutput>(candidates); if (!target.equals... | DefaultCoinSelector implements CoinSelector { @Override public CoinSelection select(Coin target, List<TransactionOutput> candidates) { ArrayList<TransactionOutput> selected = new ArrayList<TransactionOutput>(); ArrayList<TransactionOutput> sortedOutputs = new ArrayList<TransactionOutput>(candidates); if (!target.equals... | DefaultCoinSelector implements CoinSelector { @Override public CoinSelection select(Coin target, List<TransactionOutput> candidates) { ArrayList<TransactionOutput> selected = new ArrayList<TransactionOutput>(); ArrayList<TransactionOutput> sortedOutputs = new ArrayList<TransactionOutput>(candidates); if (!target.equals... | DefaultCoinSelector implements CoinSelector { @Override public CoinSelection select(Coin target, List<TransactionOutput> candidates) { ArrayList<TransactionOutput> selected = new ArrayList<TransactionOutput>(); ArrayList<TransactionOutput> sortedOutputs = new ArrayList<TransactionOutput>(candidates); if (!target.equals... |
@Test public void getSeedAsWords1() { assertEquals(12, wallet.getKeyChainSeed().getMnemonicCode().size()); } | public DeterministicSeed getKeyChainSeed() { keyChainGroupLock.lock(); try { DeterministicSeed seed = keyChainGroup.getActiveKeyChain().getSeed(); if (seed == null) throw new ECKey.MissingPrivateKeyException(); return seed; } finally { keyChainGroupLock.unlock(); } } | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public DeterministicSeed getKeyChainSeed() { keyChainGroupLock.lock(); try { DeterministicSeed seed = keyChainGroup.getActiveKeyChain().getSeed(); if (s... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public DeterministicSeed getKeyChainSeed() { keyChainGroupLock.lock(); try { DeterministicSeed seed = keyChainGroup.getActiveKeyChain().getSeed(); if (s... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public DeterministicSeed getKeyChainSeed() { keyChainGroupLock.lock(); try { DeterministicSeed seed = keyChainGroup.getActiveKeyChain().getSeed(); if (s... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public DeterministicSeed getKeyChainSeed() { keyChainGroupLock.lock(); try { DeterministicSeed seed = keyChainGroup.getActiveKeyChain().getSeed(); if (s... |
@Test public void checkSeed() throws MnemonicException { wallet.getKeyChainSeed().check(); } | public DeterministicSeed getKeyChainSeed() { keyChainGroupLock.lock(); try { DeterministicSeed seed = keyChainGroup.getActiveKeyChain().getSeed(); if (seed == null) throw new ECKey.MissingPrivateKeyException(); return seed; } finally { keyChainGroupLock.unlock(); } } | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public DeterministicSeed getKeyChainSeed() { keyChainGroupLock.lock(); try { DeterministicSeed seed = keyChainGroup.getActiveKeyChain().getSeed(); if (s... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public DeterministicSeed getKeyChainSeed() { keyChainGroupLock.lock(); try { DeterministicSeed seed = keyChainGroup.getActiveKeyChain().getSeed(); if (s... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public DeterministicSeed getKeyChainSeed() { keyChainGroupLock.lock(); try { DeterministicSeed seed = keyChainGroup.getActiveKeyChain().getSeed(); if (s... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public DeterministicSeed getKeyChainSeed() { keyChainGroupLock.lock(); try { DeterministicSeed seed = keyChainGroup.getActiveKeyChain().getSeed(); if (s... |
@Test public void basicSpendingFromP2SH() throws Exception { createMarriedWallet(2, 2); myAddress = wallet.currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS); basicSpendingCommon(wallet, myAddress, OTHER_ADDRESS, null); createMarriedWallet(2, 3); myAddress = wallet.currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS); basi... | public Address currentAddress(KeyChain.KeyPurpose purpose) { keyChainGroupLock.lock(); try { maybeUpgradeToHD(); return keyChainGroup.currentAddress(purpose); } finally { keyChainGroupLock.unlock(); } } | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public Address currentAddress(KeyChain.KeyPurpose purpose) { keyChainGroupLock.lock(); try { maybeUpgradeToHD(); return keyChainGroup.currentAddress(pur... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public Address currentAddress(KeyChain.KeyPurpose purpose) { keyChainGroupLock.lock(); try { maybeUpgradeToHD(); return keyChainGroup.currentAddress(pur... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public Address currentAddress(KeyChain.KeyPurpose purpose) { keyChainGroupLock.lock(); try { maybeUpgradeToHD(); return keyChainGroup.currentAddress(pur... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public Address currentAddress(KeyChain.KeyPurpose purpose) { keyChainGroupLock.lock(); try { maybeUpgradeToHD(); return keyChainGroup.currentAddress(pur... |
@Test public void spendingWithIncompatibleSigners() throws Exception { wallet.addTransactionSigner(new NopTransactionSigner(true)); basicSpendingCommon(wallet, myAddress, OTHER_ADDRESS, null); } | public final void addTransactionSigner(TransactionSigner signer) { lock.lock(); try { if (signer.isReady()) signers.add(signer); else throw new IllegalStateException("Signer instance is not ready to be added into Wallet: " + signer.getClass()); } finally { lock.unlock(); } } | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public final void addTransactionSigner(TransactionSigner signer) { lock.lock(); try { if (signer.isReady()) signers.add(signer); else throw new IllegalS... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public final void addTransactionSigner(TransactionSigner signer) { lock.lock(); try { if (signer.isReady()) signers.add(signer); else throw new IllegalS... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public final void addTransactionSigner(TransactionSigner signer) { lock.lock(); try { if (signer.isReady()) signers.add(signer); else throw new IllegalS... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public final void addTransactionSigner(TransactionSigner signer) { lock.lock(); try { if (signer.isReady()) signers.add(signer); else throw new IllegalS... |
@Test public void cleanup() throws Exception { Transaction t = cleanupCommon(OTHER_ADDRESS); wallet.setRiskAnalyzer(new TestRiskAnalysis.Analyzer(t)); wallet.cleanup(); assertTrue(wallet.isConsistent()); assertEquals("Wrong number of PENDING", 1, wallet.getPoolSize(WalletTransaction.Pool.PENDING)); assertEquals("Wrong ... | public void cleanup() { lock.lock(); try { boolean dirty = false; for (Iterator<Transaction> i = pending.values().iterator(); i.hasNext();) { Transaction tx = i.next(); if (isTransactionRisky(tx, null) && !acceptRiskyTransactions) { log.debug("Found risky transaction {} in wallet during cleanup.", tx.getHashAsString())... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void cleanup() { lock.lock(); try { boolean dirty = false; for (Iterator<Transaction> i = pending.values().iterator(); i.hasNext();) { Transactio... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void cleanup() { lock.lock(); try { boolean dirty = false; for (Iterator<Transaction> i = pending.values().iterator(); i.hasNext();) { Transactio... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void cleanup() { lock.lock(); try { boolean dirty = false; for (Iterator<Transaction> i = pending.values().iterator(); i.hasNext();) { Transactio... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void cleanup() { lock.lock(); try { boolean dirty = false; for (Iterator<Transaction> i = pending.values().iterator(); i.hasNext();) { Transactio... |
@Test public void balances() throws Exception { Coin nanos = COIN; Transaction tx1 = sendMoneyToWallet(AbstractBlockChain.NewBlockType.BEST_CHAIN, nanos); assertEquals(nanos, tx1.getValueSentToMe(wallet)); assertTrue(tx1.getWalletOutputs(wallet).size() >= 1); Transaction send1 = wallet.createSend(OTHER_ADDRESS, valueOf... | public Transaction createSend(Address address, Coin value) throws InsufficientMoneyException { SendRequest req = SendRequest.to(address, value); if (params.getId().equals(NetworkParameters.ID_UNITTESTNET)) req.shuffleOutputs = false; completeTx(req); return req.tx; } | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public Transaction createSend(Address address, Coin value) throws InsufficientMoneyException { SendRequest req = SendRequest.to(address, value); if (par... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public Transaction createSend(Address address, Coin value) throws InsufficientMoneyException { SendRequest req = SendRequest.to(address, value); if (par... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public Transaction createSend(Address address, Coin value) throws InsufficientMoneyException { SendRequest req = SendRequest.to(address, value); if (par... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public Transaction createSend(Address address, Coin value) throws InsufficientMoneyException { SendRequest req = SendRequest.to(address, value); if (par... |
@Test public void isTxConsistentReturnsFalseAsExpected() { Wallet wallet = new Wallet(PARAMS); TransactionOutput to = createMock(TransactionOutput.class); EasyMock.expect(to.isAvailableForSpending()).andReturn(true); EasyMock.expect(to.isMineOrWatched(wallet)).andReturn(true); EasyMock.expect(to.getSpentBy()).andReturn... | @VisibleForTesting boolean isTxConsistent(final Transaction tx, final boolean isSpent) { boolean isActuallySpent = true; for (TransactionOutput o : tx.getOutputs()) { if (o.isAvailableForSpending()) { if (o.isMineOrWatched(this)) isActuallySpent = false; if (o.getSpentBy() != null) { log.error("isAvailableForSpending !... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { @VisibleForTesting boolean isTxConsistent(final Transaction tx, final boolean isSpent) { boolean isActuallySpent = true; for (TransactionOutput o : tx.g... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { @VisibleForTesting boolean isTxConsistent(final Transaction tx, final boolean isSpent) { boolean isActuallySpent = true; for (TransactionOutput o : tx.g... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { @VisibleForTesting boolean isTxConsistent(final Transaction tx, final boolean isSpent) { boolean isActuallySpent = true; for (TransactionOutput o : tx.g... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { @VisibleForTesting boolean isTxConsistent(final Transaction tx, final boolean isSpent) { boolean isActuallySpent = true; for (TransactionOutput o : tx.g... |
@Test public void isTxConsistentReturnsFalseAsExpected_WhenAvailableForSpendingEqualsFalse() { Wallet wallet = new Wallet(PARAMS); TransactionOutput to = createMock(TransactionOutput.class); EasyMock.expect(to.isAvailableForSpending()).andReturn(false); EasyMock.expect(to.getSpentBy()).andReturn(null); Transaction tx =... | @VisibleForTesting boolean isTxConsistent(final Transaction tx, final boolean isSpent) { boolean isActuallySpent = true; for (TransactionOutput o : tx.getOutputs()) { if (o.isAvailableForSpending()) { if (o.isMineOrWatched(this)) isActuallySpent = false; if (o.getSpentBy() != null) { log.error("isAvailableForSpending !... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { @VisibleForTesting boolean isTxConsistent(final Transaction tx, final boolean isSpent) { boolean isActuallySpent = true; for (TransactionOutput o : tx.g... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { @VisibleForTesting boolean isTxConsistent(final Transaction tx, final boolean isSpent) { boolean isActuallySpent = true; for (TransactionOutput o : tx.g... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { @VisibleForTesting boolean isTxConsistent(final Transaction tx, final boolean isSpent) { boolean isActuallySpent = true; for (TransactionOutput o : tx.g... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { @VisibleForTesting boolean isTxConsistent(final Transaction tx, final boolean isSpent) { boolean isActuallySpent = true; for (TransactionOutput o : tx.g... |
@Test public void testAddTransactionsDependingOn() throws Exception { CoinSelector originalCoinSelector = wallet.getCoinSelector(); try { wallet.allowSpendingUnconfirmedTransactions(); sendMoneyToWallet(AbstractBlockChain.NewBlockType.BEST_CHAIN, valueOf(2, 0)); Transaction send1 = checkNotNull(wallet.createSend(OTHER_... | void addTransactionsDependingOn(Set<Transaction> txSet, Set<Transaction> txPool) { Map<Sha256Hash, Transaction> txQueue = new LinkedHashMap<Sha256Hash, Transaction>(); for (Transaction tx : txSet) { txQueue.put(tx.getHash(), tx); } while(!txQueue.isEmpty()) { Transaction tx = txQueue.remove(txQueue.keySet().iterator().... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { void addTransactionsDependingOn(Set<Transaction> txSet, Set<Transaction> txPool) { Map<Sha256Hash, Transaction> txQueue = new LinkedHashMap<Sha256Hash, ... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { void addTransactionsDependingOn(Set<Transaction> txSet, Set<Transaction> txPool) { Map<Sha256Hash, Transaction> txQueue = new LinkedHashMap<Sha256Hash, ... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { void addTransactionsDependingOn(Set<Transaction> txSet, Set<Transaction> txPool) { Map<Sha256Hash, Transaction> txQueue = new LinkedHashMap<Sha256Hash, ... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { void addTransactionsDependingOn(Set<Transaction> txSet, Set<Transaction> txPool) { Map<Sha256Hash, Transaction> txQueue = new LinkedHashMap<Sha256Hash, ... |
@Test public void sortTxnsByDependency() throws Exception { CoinSelector originalCoinSelector = wallet.getCoinSelector(); try { wallet.allowSpendingUnconfirmedTransactions(); Transaction send1 = sendMoneyToWallet(AbstractBlockChain.NewBlockType.BEST_CHAIN, valueOf(2, 0)); Transaction send1a = checkNotNull(wallet.create... | List<Transaction> sortTxnsByDependency(Set<Transaction> inputSet) { ArrayList<Transaction> result = new ArrayList<Transaction>(inputSet); for (int i = 0; i < result.size()-1; i++) { boolean txAtISpendsOtherTxInTheList; do { txAtISpendsOtherTxInTheList = false; for (int j = i+1; j < result.size(); j++) { if (spends(resu... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { List<Transaction> sortTxnsByDependency(Set<Transaction> inputSet) { ArrayList<Transaction> result = new ArrayList<Transaction>(inputSet); for (int i = 0... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { List<Transaction> sortTxnsByDependency(Set<Transaction> inputSet) { ArrayList<Transaction> result = new ArrayList<Transaction>(inputSet); for (int i = 0... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { List<Transaction> sortTxnsByDependency(Set<Transaction> inputSet) { ArrayList<Transaction> result = new ArrayList<Transaction>(inputSet); for (int i = 0... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { List<Transaction> sortTxnsByDependency(Set<Transaction> inputSet) { ArrayList<Transaction> result = new ArrayList<Transaction>(inputSet); for (int i = 0... |
@Test public void isWatching() { assertFalse(wallet.isWatching()); Wallet watchingWallet = Wallet.fromWatchingKey(PARAMS, wallet.getWatchingKey().dropPrivateBytes().dropParent()); assertTrue(watchingWallet.isWatching()); wallet.encrypt(PASSWORD1); assertFalse(wallet.isWatching()); } | public boolean isWatching() { keyChainGroupLock.lock(); try { maybeUpgradeToHD(); return keyChainGroup.isWatching(); } finally { keyChainGroupLock.unlock(); } } | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public boolean isWatching() { keyChainGroupLock.lock(); try { maybeUpgradeToHD(); return keyChainGroup.isWatching(); } finally { keyChainGroupLock.unloc... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public boolean isWatching() { keyChainGroupLock.lock(); try { maybeUpgradeToHD(); return keyChainGroup.isWatching(); } finally { keyChainGroupLock.unloc... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public boolean isWatching() { keyChainGroupLock.lock(); try { maybeUpgradeToHD(); return keyChainGroup.isWatching(); } finally { keyChainGroupLock.unloc... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public boolean isWatching() { keyChainGroupLock.lock(); try { maybeUpgradeToHD(); return keyChainGroup.isWatching(); } finally { keyChainGroupLock.unloc... |
@Test public void getWatchedAddresses() throws Exception { Address watchedAddress = new ECKey().toAddress(PARAMS); wallet.addWatchedAddress(watchedAddress); List<Address> watchedAddresses = wallet.getWatchedAddresses(); assertEquals(1, watchedAddresses.size()); assertEquals(watchedAddress, watchedAddresses.get(0)); } | public List<Address> getWatchedAddresses() { keyChainGroupLock.lock(); try { List<Address> addresses = new LinkedList<Address>(); for (Script script : watchedScripts) if (script.isSentToAddress()) addresses.add(script.getToAddress(params)); return addresses; } finally { keyChainGroupLock.unlock(); } } | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public List<Address> getWatchedAddresses() { keyChainGroupLock.lock(); try { List<Address> addresses = new LinkedList<Address>(); for (Script script : w... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public List<Address> getWatchedAddresses() { keyChainGroupLock.lock(); try { List<Address> addresses = new LinkedList<Address>(); for (Script script : w... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public List<Address> getWatchedAddresses() { keyChainGroupLock.lock(); try { List<Address> addresses = new LinkedList<Address>(); for (Script script : w... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public List<Address> getWatchedAddresses() { keyChainGroupLock.lock(); try { List<Address> addresses = new LinkedList<Address>(); for (Script script : w... |
@Test public void removeWatchedAddresses() { List<Address> addressesForRemoval = new ArrayList<Address>(); for (int i = 0; i < 10; i++) { Address watchedAddress = new ECKey().toAddress(PARAMS); addressesForRemoval.add(watchedAddress); wallet.addWatchedAddress(watchedAddress); } wallet.removeWatchedAddresses(addressesFo... | public boolean removeWatchedAddresses(final List<Address> addresses) { List<Script> scripts = Lists.newArrayList(); for (Address address : addresses) { Script script = ScriptBuilder.createOutputScript(address); scripts.add(script); } return removeWatchedScripts(scripts); } | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public boolean removeWatchedAddresses(final List<Address> addresses) { List<Script> scripts = Lists.newArrayList(); for (Address address : addresses) { ... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public boolean removeWatchedAddresses(final List<Address> addresses) { List<Script> scripts = Lists.newArrayList(); for (Address address : addresses) { ... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public boolean removeWatchedAddresses(final List<Address> addresses) { List<Script> scripts = Lists.newArrayList(); for (Address address : addresses) { ... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public boolean removeWatchedAddresses(final List<Address> addresses) { List<Script> scripts = Lists.newArrayList(); for (Address address : addresses) { ... |
@Test public void removeWatchedAddress() { Address watchedAddress = new ECKey().toAddress(PARAMS); wallet.addWatchedAddress(watchedAddress); wallet.removeWatchedAddress(watchedAddress); assertFalse(wallet.isAddressWatched(watchedAddress)); assertFalse(wallet.isRequiringUpdateAllBloomFilter()); } | public boolean removeWatchedAddress(final Address address) { return removeWatchedAddresses(ImmutableList.of(address)); } | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public boolean removeWatchedAddress(final Address address) { return removeWatchedAddresses(ImmutableList.of(address)); } } | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public boolean removeWatchedAddress(final Address address) { return removeWatchedAddresses(ImmutableList.of(address)); } Wallet(NetworkParameters params... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public boolean removeWatchedAddress(final Address address) { return removeWatchedAddresses(ImmutableList.of(address)); } Wallet(NetworkParameters params... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public boolean removeWatchedAddress(final Address address) { return removeWatchedAddresses(ImmutableList.of(address)); } Wallet(NetworkParameters params... |
@Test(expected = Wallet.ExceededMaxTransactionSize.class) public void respectMaxStandardSize() throws Exception { sendMoneyToWallet(AbstractBlockChain.NewBlockType.BEST_CHAIN, valueOf(100, 0)); Transaction tx = new Transaction(PARAMS); byte[] bits = new byte[20]; new Random().nextBytes(bits); Coin v = CENT; for (int i ... | public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has already been completed."); if(req.getUseForkId()) req.tx.setVersion(Transaction.CURRENT_VERSION); Coin value = Coin.ZERO; for (TransactionOutput output : req.tx.getOutputs(... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... |
@Test public void opReturnOneOutputTest() throws Exception { receiveATransaction(wallet, myAddress); Transaction tx = new Transaction(PARAMS); Coin messagePrice = Coin.ZERO; Script script = ScriptBuilder.createOpReturnScript("hello world!".getBytes()); tx.addOutput(messagePrice, script); SendRequest request = SendReque... | public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has already been completed."); if(req.getUseForkId()) req.tx.setVersion(Transaction.CURRENT_VERSION); Coin value = Coin.ZERO; for (TransactionOutput output : req.tx.getOutputs(... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... |
@Test public void opReturnMaxBytes() throws Exception { receiveATransaction(wallet, myAddress); Transaction tx = new Transaction(PARAMS); Script script = ScriptBuilder.createOpReturnScript(new byte[80]); tx.addOutput(Coin.ZERO, script); SendRequest request = SendRequest.forTx(tx); request.ensureMinRequiredFee = true; w... | public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has already been completed."); if(req.getUseForkId()) req.tx.setVersion(Transaction.CURRENT_VERSION); Coin value = Coin.ZERO; for (TransactionOutput output : req.tx.getOutputs(... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... |
@Test public void opReturnOneOutputWithValueTest() throws Exception { receiveATransaction(wallet, myAddress); Transaction tx = new Transaction(PARAMS); Coin messagePrice = CENT; Script script = ScriptBuilder.createOpReturnScript("hello world!".getBytes()); tx.addOutput(messagePrice, script); SendRequest request = SendR... | public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has already been completed."); if(req.getUseForkId()) req.tx.setVersion(Transaction.CURRENT_VERSION); Coin value = Coin.ZERO; for (TransactionOutput output : req.tx.getOutputs(... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... |
@Test public void opReturnTwoOutputsTest() throws Exception { receiveATransaction(wallet, myAddress); Transaction tx = new Transaction(PARAMS); Coin messagePrice = Coin.ZERO; Script script = ScriptBuilder.createOpReturnScript("hello world!".getBytes()); tx.addOutput(CENT, OTHER_ADDRESS); tx.addOutput(messagePrice, scri... | public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has already been completed."); if(req.getUseForkId()) req.tx.setVersion(Transaction.CURRENT_VERSION); Coin value = Coin.ZERO; for (TransactionOutput output : req.tx.getOutputs(... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... |
@Test(expected = Wallet.MultipleOpReturnRequested.class) public void twoOpReturnsPerTransactionTest() throws Exception { receiveATransaction(wallet, myAddress); Transaction tx = new Transaction(PARAMS); Coin messagePrice = Coin.ZERO; Script script1 = ScriptBuilder.createOpReturnScript("hello world 1!".getBytes()); Scri... | public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has already been completed."); if(req.getUseForkId()) req.tx.setVersion(Transaction.CURRENT_VERSION); Coin value = Coin.ZERO; for (TransactionOutput output : req.tx.getOutputs(... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... |
@Test(expected = Wallet.DustySendRequested.class) public void sendDustTest() throws InsufficientMoneyException { Transaction tx = new Transaction(PARAMS); tx.addOutput(Transaction.MIN_NONDUST_OUTPUT.subtract(SATOSHI), OTHER_ADDRESS); SendRequest request = SendRequest.forTx(tx); request.ensureMinRequiredFee = true; wall... | public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has already been completed."); if(req.getUseForkId()) req.tx.setVersion(Transaction.CURRENT_VERSION); Coin value = Coin.ZERO; for (TransactionOutput output : req.tx.getOutputs(... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... |
@Test public void sendMultipleCentsTest() throws Exception { receiveATransactionAmount(wallet, myAddress, Coin.COIN); Transaction tx = new Transaction(PARAMS); Coin c = CENT.subtract(SATOSHI); tx.addOutput(c, OTHER_ADDRESS); tx.addOutput(c, OTHER_ADDRESS); tx.addOutput(c, OTHER_ADDRESS); tx.addOutput(c, OTHER_ADDRESS);... | public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has already been completed."); if(req.getUseForkId()) req.tx.setVersion(Transaction.CURRENT_VERSION); Coin value = Coin.ZERO; for (TransactionOutput output : req.tx.getOutputs(... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... |
@Test(expected = Wallet.DustySendRequested.class) public void sendDustAndOpReturnWithoutValueTest() throws Exception { receiveATransactionAmount(wallet, myAddress, Coin.COIN); Transaction tx = new Transaction(PARAMS); tx.addOutput(Coin.ZERO, ScriptBuilder.createOpReturnScript("hello world!".getBytes())); tx.addOutput(C... | public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has already been completed."); if(req.getUseForkId()) req.tx.setVersion(Transaction.CURRENT_VERSION); Coin value = Coin.ZERO; for (TransactionOutput output : req.tx.getOutputs(... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... |
@Test(expected = Wallet.DustySendRequested.class) public void sendDustAndMessageWithValueTest() throws Exception { receiveATransaction(wallet, myAddress); Transaction tx = new Transaction(PARAMS); tx.addOutput(Coin.CENT, ScriptBuilder.createOpReturnScript("hello world!".getBytes())); tx.addOutput(Transaction.MIN_NONDUS... | public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has already been completed."); if(req.getUseForkId()) req.tx.setVersion(Transaction.CURRENT_VERSION); Coin value = Coin.ZERO; for (TransactionOutput output : req.tx.getOutputs(... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... |
@Test public void basicFeeSolverTests() throws Exception { sendMoneyToWallet(AbstractBlockChain.NewBlockType.BEST_CHAIN, Coin.COIN); SendRequest request1 = SendRequest.to(OTHER_ADDRESS, CENT.subtract(SATOSHI)); request1.ensureMinRequiredFee = true; wallet.completeTx(request1); Transaction spend1 = request1.tx; assertEq... | public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has already been completed."); if(req.getUseForkId()) req.tx.setVersion(Transaction.CURRENT_VERSION); Coin value = Coin.ZERO; for (TransactionOutput output : req.tx.getOutputs(... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... |
@Test public void exceptionsDoNotBlockAllListeners() throws Exception { wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() { @Override public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) { log.info("onCoinsReceived 1"); throw new RuntimeException("barf"... | public void addCoinsReceivedEventListener(WalletCoinsReceivedEventListener listener) { addCoinsReceivedEventListener(Threading.USER_THREAD, listener); } | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void addCoinsReceivedEventListener(WalletCoinsReceivedEventListener listener) { addCoinsReceivedEventListener(Threading.USER_THREAD, listener); }... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void addCoinsReceivedEventListener(WalletCoinsReceivedEventListener listener) { addCoinsReceivedEventListener(Threading.USER_THREAD, listener); }... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void addCoinsReceivedEventListener(WalletCoinsReceivedEventListener listener) { addCoinsReceivedEventListener(Threading.USER_THREAD, listener); }... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void addCoinsReceivedEventListener(WalletCoinsReceivedEventListener listener) { addCoinsReceivedEventListener(Threading.USER_THREAD, listener); }... |
@Test public void duplicatedBlock() { final Transaction tx = createFakeTx(PARAMS, COIN, myAddress); StoredBlock block = createFakeBlock(blockStore, Block.BLOCK_HEIGHT_GENESIS, tx).storedBlock; wallet.notifyNewBestBlock(block); wallet.notifyNewBestBlock(block); } | @Override public void notifyNewBestBlock(StoredBlock block) throws VerificationException { Sha256Hash newBlockHash = block.getHeader().getHash(); if (newBlockHash.equals(getLastBlockSeenHash())) return; lock.lock(); try { setLastBlockSeenHash(newBlockHash); setLastBlockSeenHeight(block.getHeight()); setLastBlockSeenTim... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { @Override public void notifyNewBestBlock(StoredBlock block) throws VerificationException { Sha256Hash newBlockHash = block.getHeader().getHash(); if (ne... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { @Override public void notifyNewBestBlock(StoredBlock block) throws VerificationException { Sha256Hash newBlockHash = block.getHeader().getHash(); if (ne... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { @Override public void notifyNewBestBlock(StoredBlock block) throws VerificationException { Sha256Hash newBlockHash = block.getHeader().getHash(); if (ne... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { @Override public void notifyNewBestBlock(StoredBlock block) throws VerificationException { Sha256Hash newBlockHash = block.getHeader().getHash(); if (ne... |
@Test(expected = IllegalStateException.class) public void shouldNotAddTransactionSignerThatIsNotReady() throws Exception { wallet.addTransactionSigner(new NopTransactionSigner(false)); } | public final void addTransactionSigner(TransactionSigner signer) { lock.lock(); try { if (signer.isReady()) signers.add(signer); else throw new IllegalStateException("Signer instance is not ready to be added into Wallet: " + signer.getClass()); } finally { lock.unlock(); } } | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public final void addTransactionSigner(TransactionSigner signer) { lock.lock(); try { if (signer.isReady()) signers.add(signer); else throw new IllegalS... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public final void addTransactionSigner(TransactionSigner signer) { lock.lock(); try { if (signer.isReady()) signers.add(signer); else throw new IllegalS... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public final void addTransactionSigner(TransactionSigner signer) { lock.lock(); try { if (signer.isReady()) signers.add(signer); else throw new IllegalS... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public final void addTransactionSigner(TransactionSigner signer) { lock.lock(); try { if (signer.isReady()) signers.add(signer); else throw new IllegalS... |
@Test public void sendRequestExchangeRate() throws Exception { receiveATransaction(wallet, myAddress); SendRequest sendRequest = SendRequest.to(myAddress, Coin.COIN); sendRequest.exchangeRate = new ExchangeRate(Fiat.parseFiat("EUR", "500")); wallet.completeTx(sendRequest); assertEquals(sendRequest.exchangeRate, sendReq... | public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has already been completed."); if(req.getUseForkId()) req.tx.setVersion(Transaction.CURRENT_VERSION); Coin value = Coin.ZERO; for (TransactionOutput output : req.tx.getOutputs(... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... |
@Test public void sendRequestMemo() throws Exception { receiveATransaction(wallet, myAddress); SendRequest sendRequest = SendRequest.to(myAddress, Coin.COIN); sendRequest.memo = "memo"; wallet.completeTx(sendRequest); assertEquals(sendRequest.memo, sendRequest.tx.getMemo()); } | public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has already been completed."); if(req.getUseForkId()) req.tx.setVersion(Transaction.CURRENT_VERSION); Coin value = Coin.ZERO; for (TransactionOutput output : req.tx.getOutputs(... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public void completeTx(SendRequest req) throws InsufficientMoneyException { lock.lock(); try { checkArgument(!req.completed, "Given SendRequest has alre... |
@Test(expected = java.lang.IllegalStateException.class) public void sendCoinsNoBroadcasterTest() throws InsufficientMoneyException { ECKey key = ECKey.fromPrivate(BigInteger.TEN); SendRequest req = SendRequest.to(OTHER_ADDRESS.getParameters(), key, SATOSHI.multiply(12)); wallet.sendCoins(req); } | public SendResult sendCoins(TransactionBroadcaster broadcaster, Address to, Coin value) throws InsufficientMoneyException { SendRequest request = SendRequest.to(to, value); return sendCoins(broadcaster, request); } | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public SendResult sendCoins(TransactionBroadcaster broadcaster, Address to, Coin value) throws InsufficientMoneyException { SendRequest request = SendRe... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public SendResult sendCoins(TransactionBroadcaster broadcaster, Address to, Coin value) throws InsufficientMoneyException { SendRequest request = SendRe... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public SendResult sendCoins(TransactionBroadcaster broadcaster, Address to, Coin value) throws InsufficientMoneyException { SendRequest request = SendRe... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public SendResult sendCoins(TransactionBroadcaster broadcaster, Address to, Coin value) throws InsufficientMoneyException { SendRequest request = SendRe... |
@Test public void fromKeys() { ECKey key = ECKey.fromPrivate(Utils.HEX.decode("00905b93f990267f4104f316261fc10f9f983551f9ef160854f40102eb71cffdcc")); Wallet wallet = Wallet.fromKeys(PARAMS, Arrays.asList(key)); assertEquals(1, wallet.getImportedKeys().size()); assertEquals(key, wallet.getImportedKeys().get(0)); wallet.... | public static Wallet fromKeys(NetworkParameters params, List<ECKey> keys) { for (ECKey key : keys) checkArgument(!(key instanceof DeterministicKey)); KeyChainGroup group = new KeyChainGroup(params); group.importKeys(keys); return new Wallet(params, group); } | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public static Wallet fromKeys(NetworkParameters params, List<ECKey> keys) { for (ECKey key : keys) checkArgument(!(key instanceof DeterministicKey)); Ke... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public static Wallet fromKeys(NetworkParameters params, List<ECKey> keys) { for (ECKey key : keys) checkArgument(!(key instanceof DeterministicKey)); Ke... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public static Wallet fromKeys(NetworkParameters params, List<ECKey> keys) { for (ECKey key : keys) checkArgument(!(key instanceof DeterministicKey)); Ke... | Wallet extends BaseTaggableObject implements NewBestBlockListener, TransactionReceivedInBlockListener, PeerFilterProvider, KeyBag, TransactionBag, ReorganizeListener { public static Wallet fromKeys(NetworkParameters params, List<ECKey> keys) { for (ECKey key : keys) checkArgument(!(key instanceof DeterministicKey)); Ke... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.