pochette_toshi 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 94a0ca582a90f6c8ae1d17c08b444a8b61ec15c4
4
- data.tar.gz: 66caa81b1fde7ec1b45460df226af0bb51a7c0a9
3
+ metadata.gz: cfca520a0a8b41e3ccbfcd075caa584b6b8c550c
4
+ data.tar.gz: 88f7cbc291720d623070c24a5e72b329c6f01333
5
5
  SHA512:
6
- metadata.gz: 05e5958d8a9272904bce8e8b69a2535546ca700990f3c213ac20f68fbb727d727fba6c0107b3ba8ef82f21fe78796ab9809749fc36ac3df7513f909e9f11245a
7
- data.tar.gz: 1ab462c3f6802941d8ce6b88d6746f661310a49212f32c9b875b533c526718dab1a4f8e7155ee7008705507d8bbdc066ff3b1fa9ba9400d936408e936780104e
6
+ metadata.gz: 4b1a3d944773a46f14defea6e6d02e52d398f68f7bfdee70f5f9052e5e8b832157123a5ad7b1fa31d9652923f571d8f24153ab7f3a933c9947fb9b79c17a8286
7
+ data.tar.gz: 329079e4c357dcd085402e5bf743fda8dbff4a3a26522748f920d39ac501521e5965e967fd43d8022c80bdc30b1a4f227a89d2aba942d6027bb709b1f04ec1b9
data/README.md CHANGED
@@ -4,18 +4,24 @@ A [Pochette](https://github.com/bitex-la/pochette) backend using Toshi.
4
4
 
5
5
  It will connect to your Toshi postgres database directly (not using Toshi's JSON RPC)
6
6
 
7
+ Transactions will be pushed through bitcoin
8
+
7
9
  For better performance it is recommended you create the following indexes in your
8
10
  database:
9
11
 
10
- CREATE INDEX inputs_hsh_index on inputs (hsh);
11
- CREATE INDEX inputs_is_coinbase_index on inputs (prev_out, hsh) WHERE prev_out = '0000000000000000000000000000000000000000000000000000000000000000';
12
- CREATE INDEX unspent_outputs_usable_index on unspent_outputs (amount) WHERE amount > 5000;
13
- CREATE INDEX transactions_hsh_height ON transactions (hsh, height);
12
+ ```sql
13
+ CREATE INDEX inputs_hsh_index on inputs (hsh);
14
+ CREATE INDEX inputs_is_coinbase_index on inputs (prev_out, hsh) WHERE prev_out = '0000000000000000000000000000000000000000000000000000000000000000';
15
+ CREATE INDEX unspent_outputs_usable_index on unspent_outputs (amount) WHERE amount > 5000;
16
+ CREATE INDEX transactions_hsh_height ON transactions (hsh, height);
17
+ ```
14
18
 
15
19
  You can instatiate a Toshi backend passing your postgres connection options, they will be passed
16
20
  to the pg gem [as seen in their docs](http://deveiate.org/code/pg/PG/Connection.html#method-c-new)
17
21
 
18
- >>> Pochette::Backends::Toshi.new(host: 'your-db-host', dbname: 'toshi')
22
+ ```ruby
23
+ >>> Pochette::Backends::Toshi.new(host: 'your-db-host', dbname: 'toshi')
24
+ ```
19
25
 
20
26
  ## Installation
21
27
 
@@ -35,9 +41,13 @@ Or install it yourself as:
35
41
 
36
42
  ## Development
37
43
 
38
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
44
+ After checking out the repo, run `bin/setup` to install dependencies.
45
+ Then, run `bin/console` for an interactive prompt that will allow you to experiment.
39
46
 
40
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
47
+ To install this gem onto your local machine, run `bundle exec rake install`.
48
+ To release a new version, update the version number in `version.rb`,
49
+ and then run `bundle exec rake release` to create a git tag for the version,
50
+ push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
41
51
 
42
52
  ## Contributing
43
53
 
@@ -1,3 +1,3 @@
1
1
  module PochetteToshi
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -3,6 +3,9 @@ require "active_support"
3
3
  require "active_support/core_ext"
4
4
  require "pg"
5
5
  require 'pochette'
6
+ require 'net/http'
7
+ require 'uri'
8
+ require 'oj'
6
9
 
7
10
  # This class is not properly tested.
8
11
  # Be careful when changing anything, and/or make sure
@@ -162,7 +165,7 @@ class Pochette::Backends::Toshi
162
165
 
163
166
  def list_transactions(txids)
164
167
  transactions = []
165
- addresses.in_groups_of(500, false).collect do |group|
168
+ txids.in_groups_of(500, false).collect do |group|
166
169
  transactions += list_transactions_helper(group)
167
170
  end
168
171
  transactions
@@ -210,6 +213,13 @@ class Pochette::Backends::Toshi
210
213
  def block_height
211
214
  connection.exec('select max(height) from blocks where branch = 0').values[0][0].to_i
212
215
  end
216
+
217
+ def pushtx(hex)
218
+ domain = Pochette.testnet ? 'testnet3' : 'bitcoin'
219
+ uri = URI.parse("https://#{domain}.toshi.io/api/v0/transactions")
220
+ response = Oj.load(Net::HTTP.post_form(uri, {"hex" => hex}).body)
221
+ response['hash']
222
+ end
213
223
 
214
224
  def query(sql)
215
225
  connection.exec(sql).values
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
18
  spec.require_paths = ["lib"]
19
- spec.add_dependency "pochette", "~> 0.1"
19
+ spec.add_dependency "pochette", "~> 0.1.3"
20
20
  spec.add_dependency "pg", "~> 0.17"
21
21
  spec.add_dependency "activesupport", "~> 4.2"
22
22
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pochette_toshi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nubis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-18 00:00:00.000000000 Z
11
+ date: 2015-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pochette
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.1'
19
+ version: 0.1.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.1'
26
+ version: 0.1.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pg
29
29
  requirement: !ruby/object:Gem::Requirement