glueby 0.4.4 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +463 -387
- data/glueby.gemspec +33 -33
- data/lib/generators/glueby/contract/templates/initializer.rb.erb +8 -8
- data/lib/generators/glueby/contract/templates/key_table.rb.erb +16 -16
- data/lib/generators/glueby/contract/templates/utxo_table.rb.erb +16 -16
- data/lib/glueby/block_syncer.rb +97 -97
- data/lib/glueby/configuration.rb +26 -2
- data/lib/glueby/contract/timestamp/syncer.rb +13 -13
- data/lib/glueby/contract/timestamp.rb +108 -102
- data/lib/glueby/contract/token.rb +270 -244
- data/lib/glueby/contract/tx_builder.rb +97 -30
- data/lib/glueby/fee_provider/tasks.rb +140 -140
- data/lib/glueby/fee_provider.rb +11 -0
- data/lib/glueby/internal/wallet/abstract_wallet_adapter.rb +151 -151
- data/lib/glueby/internal/wallet/active_record/utxo.rb +51 -51
- data/lib/glueby/internal/wallet/active_record_wallet_adapter/syncer.rb +13 -13
- data/lib/glueby/internal/wallet/active_record_wallet_adapter.rb +151 -151
- data/lib/glueby/internal/wallet/tapyrus_core_wallet_adapter.rb +186 -186
- data/lib/glueby/internal/wallet.rb +163 -162
- data/lib/glueby/railtie.rb +10 -9
- data/lib/glueby/utxo_provider/tasks.rb +135 -0
- data/lib/glueby/utxo_provider.rb +85 -0
- data/lib/glueby/version.rb +3 -3
- data/lib/glueby.rb +40 -39
- data/lib/tasks/glueby/block_syncer.rake +28 -28
- data/lib/tasks/glueby/contract/timestamp.rake +46 -39
- data/lib/tasks/glueby/fee_provider.rake +18 -18
- data/lib/tasks/glueby/utxo_provider.rake +18 -0
- metadata +5 -2
@@ -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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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.
|
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
|
+
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-
|
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
|