glueby 1.2.0 → 1.2.1

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
  SHA256:
3
- metadata.gz: 9dceda38ccaf2ef4b7c99ee5f585c53d49cedbb3786ae38aaf76580373e7abc6
4
- data.tar.gz: cf38bf63c04f586999bf7cc0ba86068606500bdec11b75143716e9dfba233c8e
3
+ metadata.gz: d24ac7453ad1f867e539ac7d602fd2eb05be9b8cbf2b961d7543455ade732b38
4
+ data.tar.gz: 97bf9172250dd6ff7f1858df2d193c0f702166de46464684259427187ef3c87c
5
5
  SHA512:
6
- metadata.gz: 796be14f4309672bdc55c3475a55e7edc46e3a1676d59b2f7038bb643bbf5bd1ced0d342927a0b64640b63988ec9540ed7aaf9d21d1283e9aaeeae004494da27
7
- data.tar.gz: b5b8509ff80cd48bdefd1fea80b63df15bf83d2ca73ade56602435a3db49100fa98f3c58659a85d74163bcd9532d4c319f201dc2e5d8b47e44a8b0060dd6f8f3
6
+ metadata.gz: bd8f001ac884309b2bc1130ba10960bb433d7ef4eb1730e49de060bd343e604d78437e0293b1945e7258be5d03732d7b527755745bfaed19cd2c6ce659387bb3
7
+ data.tar.gz: 22ba0d8435451c88943ef4720887e38744477d9a321d61df0a6d15a8ea5f78b568398f8bfa4c8076b6288f9940b00aaf321668294284ec8b57c5effb92d6575b
@@ -1,8 +1,8 @@
1
- # Edit configuration for connection to tapyrus core
2
- Glueby.configure do |config|
3
- config.wallet_adapter = :activerecord
4
- config.rpc_config = { schema: 'http', host: '127.0.0.1', port: 12381, user: 'user', password: 'pass' }
5
- end
6
-
7
- # Uncomment next line when using timestamp feature
8
- # Glueby::BlockSyncer.register_syncer(Glueby::Contract::Timestamp::Syncer)
1
+ # Edit configuration for connection to tapyrus core
2
+ Glueby.configure do |config|
3
+ config.wallet_adapter = :activerecord
4
+ config.rpc_config = { schema: 'http', host: '127.0.0.1', port: 12381, user: 'user', password: 'pass' }
5
+ end
6
+
7
+ # Uncomment next line when using timestamp feature
8
+ # Glueby::BlockSyncer.register_syncer(Glueby::Contract::Timestamp::Syncer)
@@ -1,16 +1,16 @@
1
- class CreateKey < ActiveRecord::Migration<%= migration_version %>
2
- def change
3
- create_table :glueby_keys<%= table_options %> do |t|
4
- t.string :private_key
5
- t.string :public_key
6
- t.string :script_pubkey
7
- t.string :label, index: true
8
- t.integer :purpose
9
- t.belongs_to :wallet
10
- t.timestamps
11
- end
12
-
13
- add_index :glueby_keys, [:script_pubkey], unique: true
14
- add_index :glueby_keys, [:private_key], unique: true
15
- end
16
- end
1
+ class CreateKey < ActiveRecord::Migration<%= migration_version %>
2
+ def change
3
+ create_table :glueby_keys<%= table_options %> do |t|
4
+ t.string :private_key
5
+ t.string :public_key
6
+ t.string :script_pubkey
7
+ t.string :label, index: true
8
+ t.integer :purpose
9
+ t.belongs_to :wallet
10
+ t.timestamps
11
+ end
12
+
13
+ add_index :glueby_keys, [:script_pubkey], unique: true
14
+ add_index :glueby_keys, [:private_key], unique: true
15
+ end
16
+ end
@@ -1,98 +1,98 @@
1
- module Glueby
2
- # You can use BlockSyncer when you need to synchronize the state of
3
- # an application with the state of a blockchain. When BlockSyncer
4
- # detects the generation of a new block, it executes the registered
5
- # syncer code on a block-by-block or transaction-by-transaction basis.
6
- # By using this, an application can detect that the issued transaction
7
- # has been captured in blocks, receive a new remittance, and so on.
8
- #
9
- # # Syncer logic registration
10
- #
11
- # For registration, create a class that implements the method that performs
12
- # synchronization processing and registers it in BlockSyncer. Implement
13
- # methods with the following name in that class.
14
- #
15
- # Method name | Arguments | Call conditions
16
- # ------------------ | --------------------- | ------------------------------
17
- # block_sync (block) | block: Tapyrus::Block | When a new block is created
18
- # block_tx (tx) | tx: Tapyrus::Tx | When a new block is created, it is executed for each tx contained in that block.
19
- #
20
- # @example Register a synchronous logic
21
- # class Syncer
22
- # def block_sync (block)
23
- # # sync a block
24
- # end
25
- #
26
- # def tx_sync (tx)
27
- # # sync a tx
28
- # end
29
- # end
30
- # BlockSyncer.register_syncer(Syncer)
31
- #
32
- # @example Unregister the synchronous logic
33
- # BlockSyncer.unregister_syncer(Syncer)
34
- #
35
- # # Run BlockSyncer
36
- #
37
- # Run the `glueby: block_syncer: start` rake task periodically with a program
38
- # for periodic execution such as cron. If it detects the generation of a new
39
- # block when it is executed, the synchronization process will be executed.
40
- # Determine the execution interval according to the requirements of the application.
41
- class BlockSyncer
42
- # @!attribute [r] height
43
- # @return [Integer] The block height to be synced
44
- attr_reader :height
45
-
46
- class << self
47
- # @!attribute r syncers
48
- # @return [Array<Class>] The syncer classes that is registered
49
- attr_reader :syncers
50
-
51
- # Register syncer class
52
- # @param [Class] syncer The syncer to be registered.
53
- def register_syncer(syncer)
54
- @syncers ||= []
55
- @syncers << syncer
56
- end
57
-
58
- # Unregister syncer class
59
- # @param [Class] syncer The syncer to be unregistered.
60
- def unregister_syncer(syncer)
61
- @syncers ||= []
62
- @syncers.delete(syncer)
63
- end
64
- end
65
-
66
- # @param [Integer] height The block height to be synced in the instance
67
- def initialize(height)
68
- @height = height
69
- end
70
-
71
- # Run a block synchronization
72
- def run
73
- return if self.class.syncers.nil?
74
-
75
- self.class.syncers.each do |syncer|
76
- instance = syncer.new
77
- instance.block_sync(block) if instance.respond_to?(:block_sync)
78
-
79
- if instance.respond_to?(:tx_sync)
80
- block.transactions.each { |tx| instance.tx_sync(tx) }
81
- end
82
- end
83
- end
84
-
85
- private
86
-
87
- def block
88
- @block ||= begin
89
- block = Glueby::Internal::RPC.client.getblock(block_hash, 0)
90
- Tapyrus::Block.parse_from_payload(block.htb)
91
- end
92
- end
93
-
94
- def block_hash
95
- @block_hash ||= Glueby::Internal::RPC.client.getblockhash(height)
96
- end
97
- end
1
+ module Glueby
2
+ # You can use BlockSyncer when you need to synchronize the state of
3
+ # an application with the state of a blockchain. When BlockSyncer
4
+ # detects the generation of a new block, it executes the registered
5
+ # syncer code on a block-by-block or transaction-by-transaction basis.
6
+ # By using this, an application can detect that the issued transaction
7
+ # has been captured in blocks, receive a new remittance, and so on.
8
+ #
9
+ # # Syncer logic registration
10
+ #
11
+ # For registration, create a class that implements the method that performs
12
+ # synchronization processing and registers it in BlockSyncer. Implement
13
+ # methods with the following name in that class.
14
+ #
15
+ # Method name | Arguments | Call conditions
16
+ # ------------------ | --------------------- | ------------------------------
17
+ # block_sync (block) | block: Tapyrus::Block | When a new block is created
18
+ # block_tx (tx) | tx: Tapyrus::Tx | When a new block is created, it is executed for each tx contained in that block.
19
+ #
20
+ # @example Register a synchronous logic
21
+ # class Syncer
22
+ # def block_sync (block)
23
+ # # sync a block
24
+ # end
25
+ #
26
+ # def tx_sync (tx)
27
+ # # sync a tx
28
+ # end
29
+ # end
30
+ # BlockSyncer.register_syncer(Syncer)
31
+ #
32
+ # @example Unregister the synchronous logic
33
+ # BlockSyncer.unregister_syncer(Syncer)
34
+ #
35
+ # # Run BlockSyncer
36
+ #
37
+ # Run the `glueby: block_syncer: start` rake task periodically with a program
38
+ # for periodic execution such as cron. If it detects the generation of a new
39
+ # block when it is executed, the synchronization process will be executed.
40
+ # Determine the execution interval according to the requirements of the application.
41
+ class BlockSyncer
42
+ # @!attribute [r] height
43
+ # @return [Integer] The block height to be synced
44
+ attr_reader :height
45
+
46
+ class << self
47
+ # @!attribute r syncers
48
+ # @return [Array<Class>] The syncer classes that is registered
49
+ attr_reader :syncers
50
+
51
+ # Register syncer class
52
+ # @param [Class] syncer The syncer to be registered.
53
+ def register_syncer(syncer)
54
+ @syncers ||= []
55
+ @syncers << syncer
56
+ end
57
+
58
+ # Unregister syncer class
59
+ # @param [Class] syncer The syncer to be unregistered.
60
+ def unregister_syncer(syncer)
61
+ @syncers ||= []
62
+ @syncers.delete(syncer)
63
+ end
64
+ end
65
+
66
+ # @param [Integer] height The block height to be synced in the instance
67
+ def initialize(height)
68
+ @height = height
69
+ end
70
+
71
+ # Run a block synchronization
72
+ def run
73
+ return if self.class.syncers.nil?
74
+
75
+ self.class.syncers.each do |syncer|
76
+ instance = syncer.new
77
+ instance.block_sync(block) if instance.respond_to?(:block_sync)
78
+
79
+ if instance.respond_to?(:tx_sync)
80
+ block.transactions.each { |tx| instance.tx_sync(tx) }
81
+ end
82
+ end
83
+ end
84
+
85
+ private
86
+
87
+ def block
88
+ @block ||= begin
89
+ block = Glueby::Internal::RPC.client.getblock(block_hash, 0)
90
+ Tapyrus::Block.parse_from_payload(block.htb)
91
+ end
92
+ end
93
+
94
+ def block_hash
95
+ @block_hash ||= Glueby::Internal::RPC.client.getblockhash(height)
96
+ end
97
+ end
98
98
  end
@@ -22,10 +22,7 @@ module Glueby
22
22
  @prefix = prefix
23
23
  @data = data
24
24
 
25
- contents = [prefix, data].map do |content|
26
- content.bytes.map { |i| i.to_s(16) }.join
27
- end
28
-
25
+ contents = [prefix, data].map(&:bth)
29
26
  @txb.data(*contents)
30
27
  self
31
28
  end
@@ -1,3 +1,3 @@
1
1
  module Glueby
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glueby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - azuchi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-08 00:00:00.000000000 Z
11
+ date: 2023-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tapyrus