bitcoin2graphdb 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/bitcoin2graphdb/version.rb +1 -1
- data/lib/graphdb.rb +11 -0
- data/lib/graphdb/configuration.rb +14 -0
- data/lib/graphdb/model.rb +1 -1
- data/lib/graphdb/model/active_node_base.rb +3 -0
- data/lib/graphdb/model/extensions.rb +22 -0
- data/lib/graphdb/model/extensions/base.rb +15 -0
- data/lib/graphdb/model/extensions/open_assets.rb +11 -0
- data/lib/graphdb/model/extensions/open_assets/oa_transaction.rb +24 -0
- data/lib/graphdb/model/transaction.rb +2 -0
- data/lib/graphdb/model/tx_in.rb +12 -0
- data/lib/graphdb/model/tx_out.rb +12 -0
- metadata +7 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 55b1eb9d3024b24308bb0c1ae4268eccc5a97591
         | 
| 4 | 
            +
              data.tar.gz: d481780673fc69dba52669c77b323b96dc70064d
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: f6dbe2b91830b2dccbf0a294e549d5bfc940534eeed7f101c22ddd39b624bcf36979fc58b2eff0c68645831841c0bf872fddc7ee2ae5bcab5a0ebeacc90c5268
         | 
| 7 | 
            +
              data.tar.gz: 47f705deaacb59bfa8ed9228024efa164a42bb49a1d4f089f00909362d694f07316b037457550d555a3bf018035609418e416578d5f78964cca8fd0b270b038d
         | 
    
        data/README.md
    CHANGED
    
    
    
        data/lib/graphdb.rb
    CHANGED
    
    | @@ -2,4 +2,15 @@ require 'neo4j' | |
| 2 2 |  | 
| 3 3 | 
             
            module Graphdb
         | 
| 4 4 | 
             
              autoload :Model, 'graphdb/model'
         | 
| 5 | 
            +
              autoload :Configuration, 'graphdb/configuration'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              def self.configuration
         | 
| 8 | 
            +
                @configuration ||= Graphdb::Configuration.new
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              def self.configure
         | 
| 12 | 
            +
                yield configuration if block_given?
         | 
| 13 | 
            +
                configuration.load_extensions
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
             | 
| 5 16 | 
             
            end
         | 
    
        data/lib/graphdb/model.rb
    CHANGED
    
    | @@ -1,11 +1,11 @@ | |
| 1 1 | 
             
            module Graphdb
         | 
| 2 2 | 
             
              module Model
         | 
| 3 | 
            -
                autoload :Database, 'graphdb/model/database'
         | 
| 4 3 | 
             
                autoload :ActiveNodeBase, 'graphdb/model/active_node_base'
         | 
| 5 4 | 
             
                autoload :Block, 'graphdb/model/block'
         | 
| 6 5 | 
             
                autoload :Transaction, 'graphdb/model/transaction'
         | 
| 7 6 | 
             
                autoload :TxIn, 'graphdb/model/tx_in'
         | 
| 8 7 | 
             
                autoload :TxOut, 'graphdb/model/tx_out'
         | 
| 9 8 | 
             
                autoload :Address, 'graphdb/model/address'
         | 
| 9 | 
            +
                autoload :Extensions, 'graphdb/model/extensions'
         | 
| 10 10 | 
             
              end
         | 
| 11 11 | 
             
            end
         | 
| @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            module Graphdb
         | 
| 2 | 
            +
              module Model
         | 
| 3 | 
            +
                module Extensions
         | 
| 4 | 
            +
                  autoload :Base, 'graphdb/model/extensions/base'
         | 
| 5 | 
            +
                  autoload :OpenAssets, 'graphdb/model/extensions/open_assets'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                  EXTENSIONS = {open_assets: 'graphdb/model/extensions/open_assets'}
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                  attr_accessor :extensions
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  def load_extensions
         | 
| 12 | 
            +
                    extensions.each do |e|
         | 
| 13 | 
            +
                      load_module = "Graphdb::Model::Extensions::#{e.camelize}".constantize
         | 
| 14 | 
            +
                      load_module::EXTENSIONS_TARGETS.each do |target|
         | 
| 15 | 
            +
                        target.origin_class.include target
         | 
| 16 | 
            +
                      end
         | 
| 17 | 
            +
                    end
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
            end
         | 
| @@ -0,0 +1,24 @@ | |
| 1 | 
            +
            module Graphdb
         | 
| 2 | 
            +
              module Model
         | 
| 3 | 
            +
                module Extensions
         | 
| 4 | 
            +
                  module OpenAssets
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                    module OaTransaction
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                      extend Graphdb::Model::Extensions::Base
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                      def self.included(base)
         | 
| 11 | 
            +
                        base.class_eval do
         | 
| 12 | 
            +
                          # asset output type (:issuance, :transfer, :uncolored)
         | 
| 13 | 
            +
                          property :output_type
         | 
| 14 | 
            +
                        end
         | 
| 15 | 
            +
                      end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                      set_origin Graphdb::Model::Transaction
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                    end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
            end
         | 
    
        data/lib/graphdb/model/tx_in.rb
    CHANGED
    
    | @@ -10,9 +10,12 @@ module Graphdb | |
| 10 10 | 
             
                  property :sequence
         | 
| 11 11 |  | 
| 12 12 | 
             
                  has_one :out, :transaction, type: :transaction, model_class: Transaction
         | 
| 13 | 
            +
                  has_one :in, :out_point, origin: :out_point, model_class: TxOut
         | 
| 13 14 |  | 
| 14 15 | 
             
                  validates :sequence, :presence => true
         | 
| 15 16 |  | 
| 17 | 
            +
                  after_create :add_out_point_rel
         | 
| 18 | 
            +
             | 
| 16 19 | 
             
                  def self.create_from_hash(hash)
         | 
| 17 20 | 
             
                    tx_in = new
         | 
| 18 21 | 
             
                    tx_in.txid = hash['txid']
         | 
| @@ -27,6 +30,15 @@ module Graphdb | |
| 27 30 | 
             
                    tx_in
         | 
| 28 31 | 
             
                  end
         | 
| 29 32 |  | 
| 33 | 
            +
                  private
         | 
| 34 | 
            +
                  def add_out_point_rel
         | 
| 35 | 
            +
                    tx_out = Graphdb::Model::TxOut.find_by_outpoint(self.txid, self.vout)
         | 
| 36 | 
            +
                    if tx_out
         | 
| 37 | 
            +
                      self.out_point = tx_out
         | 
| 38 | 
            +
                      save!
         | 
| 39 | 
            +
                    end
         | 
| 40 | 
            +
                  end
         | 
| 41 | 
            +
             | 
| 30 42 | 
             
                end
         | 
| 31 43 | 
             
              end
         | 
| 32 44 | 
             
            end
         | 
    
        data/lib/graphdb/model/tx_out.rb
    CHANGED
    
    | @@ -11,10 +11,13 @@ module Graphdb | |
| 11 11 |  | 
| 12 12 | 
             
                  has_one :out, :transaction, type: :transaction, model_class: Transaction
         | 
| 13 13 | 
             
                  has_many :out, :addresses, type: :address, model_class: Address
         | 
| 14 | 
            +
                  has_one :out, :out_point, type: :spent_input, model_class: TxIn
         | 
| 14 15 |  | 
| 15 16 | 
             
                  validates :value, :presence => true
         | 
| 16 17 | 
             
                  validates :n, :presence => true
         | 
| 17 18 |  | 
| 19 | 
            +
                  scope :with_out_index, -> (n){where(n: n)}
         | 
| 20 | 
            +
             | 
| 18 21 | 
             
                  def self.create_from_hash(hash)
         | 
| 19 22 | 
             
                    tx_out = new
         | 
| 20 23 | 
             
                    tx_out.value = hash['value']
         | 
| @@ -35,6 +38,15 @@ module Graphdb | |
| 35 38 | 
             
                    tx_out
         | 
| 36 39 | 
             
                  end
         | 
| 37 40 |  | 
| 41 | 
            +
                  def self.find_by_outpoint(txid, n)
         | 
| 42 | 
            +
                    tx = Graphdb::Model::Transaction.with_txid(txid).first
         | 
| 43 | 
            +
                    if tx
         | 
| 44 | 
            +
                      tx.outputs.each{|o|
         | 
| 45 | 
            +
                        return o if o.n == n
         | 
| 46 | 
            +
                      }
         | 
| 47 | 
            +
                    end
         | 
| 48 | 
            +
                  end
         | 
| 49 | 
            +
             | 
| 38 50 | 
             
                end
         | 
| 39 51 | 
             
              end
         | 
| 40 52 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: bitcoin2graphdb
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - azuchi
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2016-03- | 
| 11 | 
            +
            date: 2016-03-08 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: openassets-ruby
         | 
| @@ -151,10 +151,15 @@ files: | |
| 151 151 | 
             
            - lib/bitcoin2graphdb/migration.rb
         | 
| 152 152 | 
             
            - lib/bitcoin2graphdb/version.rb
         | 
| 153 153 | 
             
            - lib/graphdb.rb
         | 
| 154 | 
            +
            - lib/graphdb/configuration.rb
         | 
| 154 155 | 
             
            - lib/graphdb/model.rb
         | 
| 155 156 | 
             
            - lib/graphdb/model/active_node_base.rb
         | 
| 156 157 | 
             
            - lib/graphdb/model/address.rb
         | 
| 157 158 | 
             
            - lib/graphdb/model/block.rb
         | 
| 159 | 
            +
            - lib/graphdb/model/extensions.rb
         | 
| 160 | 
            +
            - lib/graphdb/model/extensions/base.rb
         | 
| 161 | 
            +
            - lib/graphdb/model/extensions/open_assets.rb
         | 
| 162 | 
            +
            - lib/graphdb/model/extensions/open_assets/oa_transaction.rb
         | 
| 158 163 | 
             
            - lib/graphdb/model/transaction.rb
         | 
| 159 164 | 
             
            - lib/graphdb/model/tx_in.rb
         | 
| 160 165 | 
             
            - lib/graphdb/model/tx_out.rb
         |