glueby 0.4.4 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,29 +1,29 @@
1
- namespace :glueby do
2
- namespace :contract do
3
- namespace :block_syncer do
4
- desc '[Deprecated use glueby:block_syncer:start instead] sync block into database'
5
- task :start, [] => [:environment] do |_, _|
6
- puts '[Deprecated] glueby:contract:block_syncer:start is deprecated. Use \'glueby:block_syncer:start\''
7
- Rake::Task['glueby:block_syncer:start'].execute
8
- end
9
- end
10
- end
11
- end
12
-
13
-
14
- namespace :glueby do
15
- namespace :block_syncer do
16
- desc 'sync block into database'
17
- task :start, [] => [:environment] do |_, _|
18
- latest_block_num = Glueby::Internal::RPC.client.getblockcount
19
- synced_block = Glueby::AR::SystemInformation.synced_block_height
20
- (synced_block.int_value + 1..latest_block_num).each do |height|
21
- ::ActiveRecord::Base.transaction do
22
- Glueby::BlockSyncer.new(height).run
23
- synced_block.update(info_value: height.to_s)
24
- end
25
- puts "success in synchronization (block height=#{height})"
26
- end
27
- end
28
- end
1
+ namespace :glueby do
2
+ namespace :contract do
3
+ namespace :block_syncer do
4
+ desc '[Deprecated use glueby:block_syncer:start instead] sync block into database'
5
+ task :start, [] => [:environment] do |_, _|
6
+ puts '[Deprecated] glueby:contract:block_syncer:start is deprecated. Use \'glueby:block_syncer:start\''
7
+ Rake::Task['glueby:block_syncer:start'].execute
8
+ end
9
+ end
10
+ end
11
+ end
12
+
13
+
14
+ namespace :glueby do
15
+ namespace :block_syncer do
16
+ desc 'sync block into database'
17
+ task :start, [] => [:environment] do |_, _|
18
+ latest_block_num = Glueby::Internal::RPC.client.getblockcount
19
+ synced_block = Glueby::AR::SystemInformation.synced_block_height
20
+ (synced_block.int_value + 1..latest_block_num).each do |height|
21
+ ::ActiveRecord::Base.transaction do
22
+ Glueby::BlockSyncer.new(height).run
23
+ synced_block.update(info_value: height.to_s)
24
+ end
25
+ puts "success in synchronization (block height=#{height})"
26
+ end
27
+ end
28
+ end
29
29
  end
@@ -1,40 +1,47 @@
1
- module Glueby
2
- module Contract
3
- module Task
4
- module Timestamp
5
- module_function
6
- extend Glueby::Contract::TxBuilder
7
- extend Glueby::Contract::Timestamp::Util
8
-
9
- def create
10
- timestamps = Glueby::Contract::AR::Timestamp.where(status: :init)
11
- timestamps.each do |t|
12
- begin
13
- ::ActiveRecord::Base.transaction do
14
- wallet = Glueby::Wallet.load(t.wallet_id)
15
- tx = create_tx(wallet, t.prefix, t.content_hash, Glueby::Contract::FixedFeeEstimator.new)
16
- wallet.internal_wallet.broadcast(tx) do |tx|
17
- t.update(txid: tx.txid, status: :unconfirmed)
18
- end
19
- puts "broadcasted (id=#{t.id}, txid=#{tx.txid})"
20
- end
21
- rescue => e
22
- puts "failed to broadcast (id=#{t.id}, reason=#{e.message})"
23
- end
24
- end
25
- end
26
- end
27
- end
28
- end
29
- end
30
-
31
- namespace :glueby do
32
- namespace :contract do
33
- namespace :timestamp do
34
- desc 'create and broadcast glueby timestamp tx'
35
- task :create, [] => [:environment] do |_, _|
36
- Glueby::Contract::Task::Timestamp.create
37
- end
38
- end
39
- end
1
+ module Glueby
2
+ module Contract
3
+ module Task
4
+ module Timestamp
5
+ module_function
6
+ extend Glueby::Contract::TxBuilder
7
+ extend Glueby::Contract::Timestamp::Util
8
+
9
+ def create
10
+ timestamps = Glueby::Contract::AR::Timestamp.where(status: :init)
11
+ utxo_provider = Glueby::UtxoProvider.new if Glueby.configuration.use_utxo_provider?
12
+ timestamps.each do |t|
13
+ begin
14
+ wallet = Glueby::Wallet.load(t.wallet_id)
15
+ funding_tx, tx = create_txs(wallet, t.prefix, t.content_hash, Glueby::Contract::FixedFeeEstimator.new, utxo_provider)
16
+ if funding_tx
17
+ ::ActiveRecord::Base.transaction do
18
+ wallet.internal_wallet.broadcast(funding_tx)
19
+ puts "funding tx was broadcasted(id=#{t.id}, funding_tx.txid=#{funding_tx.txid})"
20
+ end
21
+ end
22
+ ::ActiveRecord::Base.transaction do
23
+ wallet.internal_wallet.broadcast(tx) do |tx|
24
+ t.update(txid: tx.txid, status: :unconfirmed)
25
+ end
26
+ puts "timestamp tx was broadcasted (id=#{t.id}, txid=#{tx.txid})"
27
+ end
28
+ rescue => e
29
+ puts "failed to broadcast (id=#{t.id}, reason=#{e.message})"
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ namespace :glueby do
39
+ namespace :contract do
40
+ namespace :timestamp do
41
+ desc 'create and broadcast glueby timestamp tx'
42
+ task :create, [] => [:environment] do |_, _|
43
+ Glueby::Contract::Task::Timestamp.create
44
+ end
45
+ end
46
+ end
40
47
  end
@@ -1,18 +1,18 @@
1
- namespace :glueby do
2
- namespace :fee_provider do
3
- desc 'Manage the UTXO pool in Glueby::FeeProvider. Creates outputs for paying fee if the outputs is less than configured pool size by :utxo_pool_size'
4
- task :manage_utxo_pool, [] => [:environment] do |_, _|
5
- Glueby::FeeProvider::Tasks.new.manage_utxo_pool
6
- end
7
-
8
- desc 'Show the status of the UTXO pool in Glueby::FeeProvider'
9
- task :status, [] => [:environment] do |_, _|
10
- Glueby::FeeProvider::Tasks.new.status
11
- end
12
-
13
- desc 'Show the address of the Glueby::FeeProvider'
14
- task :address, [] => [:environment] do |_, _|
15
- Glueby::FeeProvider::Tasks.new.address
16
- end
17
- end
18
- end
1
+ namespace :glueby do
2
+ namespace :fee_provider do
3
+ desc 'Manage the UTXO pool in Glueby::FeeProvider. Creates outputs for paying fee if the outputs is less than configured pool size by :utxo_pool_size'
4
+ task :manage_utxo_pool, [] => [:environment] do |_, _|
5
+ Glueby::FeeProvider::Tasks.new.manage_utxo_pool
6
+ end
7
+
8
+ desc 'Show the status of the UTXO pool in Glueby::FeeProvider'
9
+ task :status, [] => [:environment] do |_, _|
10
+ Glueby::FeeProvider::Tasks.new.status
11
+ end
12
+
13
+ desc 'Show the address of the Glueby::FeeProvider'
14
+ task :address, [] => [:environment] do |_, _|
15
+ Glueby::FeeProvider::Tasks.new.print_address
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ namespace :glueby do
2
+ namespace :utxo_provider do
3
+ desc 'Manage the UTXO pool in Glueby::UtxoProvider. Creates outputs for paying utxo if the outputs is less than configured pool size by :utxo_pool_size'
4
+ task :manage_utxo_pool, [] => [:environment] do |_, _|
5
+ Glueby::UtxoProvider::Tasks.new.manage_utxo_pool
6
+ end
7
+
8
+ desc 'Show the status of the UTXO pool in Glueby::UtxoProvider'
9
+ task :status, [] => [:environment] do |_, _|
10
+ Glueby::UtxoProvider::Tasks.new.status
11
+ end
12
+
13
+ desc 'Show the address of the Glueby::UtxoProvider'
14
+ task :address, [] => [:environment] do |_, _|
15
+ Glueby::UtxoProvider::Tasks.new.print_address
16
+ end
17
+ end
18
+ 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: 0.4.4
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - azuchi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-13 00:00:00.000000000 Z
11
+ date: 2021-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tapyrus
@@ -131,12 +131,15 @@ files:
131
131
  - lib/glueby/internal/wallet/errors.rb
132
132
  - lib/glueby/internal/wallet/tapyrus_core_wallet_adapter.rb
133
133
  - lib/glueby/railtie.rb
134
+ - lib/glueby/utxo_provider.rb
135
+ - lib/glueby/utxo_provider/tasks.rb
134
136
  - lib/glueby/version.rb
135
137
  - lib/glueby/wallet.rb
136
138
  - lib/tasks/glueby/block_syncer.rake
137
139
  - lib/tasks/glueby/contract.rake
138
140
  - lib/tasks/glueby/contract/timestamp.rake
139
141
  - lib/tasks/glueby/fee_provider.rake
142
+ - lib/tasks/glueby/utxo_provider.rake
140
143
  homepage: https://github.com/chaintope/glueby
141
144
  licenses:
142
145
  - MIT