Skip to content
1 change: 1 addition & 0 deletions app/models/blockchain/mainnet_block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#
# Indexes
#
# index_blockchain_mainnet_blocks_on_blockhash (blockhash)
# index_blockchain_mainnet_blocks_on_slot_number (slot_number)
#
class Blockchain::MainnetBlock < Blockchain::Block
Expand Down
26 changes: 14 additions & 12 deletions app/models/blockchain/mainnet_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@
#
# Table name: blockchain_mainnet_transactions
#
# id :bigint not null, primary key
# account_key_1 :string(191)
# account_key_2 :string(191)
# account_key_3 :string(191)
# epoch :integer
# fee :bigint
# post_balances :text(65535)
# pre_balances :text(65535)
# slot_number :bigint
# created_at :datetime not null
# updated_at :datetime not null
# block_id :bigint
# id :bigint not null, primary key
# account_key_1 :string(191)
# account_key_2 :string(191)
# account_key_3 :string(191)
# epoch :integer
# fee :bigint
# post_balances :text(65535)
# pre_balances :text(65535)
# recent_blockhash :string(191)
# slot_number :bigint
# created_at :datetime not null
# updated_at :datetime not null
# block_id :bigint
#
# Indexes
#
# index_blockchain_mainnet_transactions_on_block_id (block_id)
# index_blockchain_mainnet_transactions_on_epoch (epoch)
#
class Blockchain::MainnetTransaction < Blockchain::Transaction
belongs_to :block, class_name: 'Blockchain::MainnetBlock', foreign_key: 'block_id', validate: false, optional: true
Expand Down
25 changes: 13 additions & 12 deletions app/models/blockchain/mainnet_transaction_archive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
#
# Table name: blockchain_mainnet_transaction_archives
#
# id :bigint not null, primary key
# account_key_1 :string(191)
# account_key_2 :string(191)
# account_key_3 :string(191)
# epoch :integer
# fee :bigint
# post_balances :text(65535)
# pre_balances :text(65535)
# slot_number :bigint
# created_at :datetime not null
# updated_at :datetime not null
# block_id :bigint
# id :bigint not null, primary key
# account_key_1 :string(191)
# account_key_2 :string(191)
# account_key_3 :string(191)
# epoch :integer
# fee :bigint
# post_balances :text(65535)
# pre_balances :text(65535)
# recent_blockhash :string(191)
# slot_number :bigint
# created_at :datetime not null
# updated_at :datetime not null
# block_id :bigint
#
class Blockchain::MainnetTransactionArchive < Blockchain::Archive
end
1 change: 1 addition & 0 deletions app/models/blockchain/pythnet_block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#
# Indexes
#
# index_blockchain_pythnet_blocks_on_blockhash (blockhash)
# index_blockchain_pythnet_blocks_on_slot_number (slot_number)
#
class Blockchain::PythnetBlock < Blockchain::Block
Expand Down
26 changes: 14 additions & 12 deletions app/models/blockchain/pythnet_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@
#
# Table name: blockchain_pythnet_transactions
#
# id :bigint not null, primary key
# account_key_1 :string(191)
# account_key_2 :string(191)
# account_key_3 :string(191)
# epoch :integer
# fee :bigint
# post_balances :text(65535)
# pre_balances :text(65535)
# slot_number :bigint
# created_at :datetime not null
# updated_at :datetime not null
# block_id :bigint
# id :bigint not null, primary key
# account_key_1 :string(191)
# account_key_2 :string(191)
# account_key_3 :string(191)
# epoch :integer
# fee :bigint
# post_balances :text(65535)
# pre_balances :text(65535)
# recent_blockhash :string(191)
# slot_number :bigint
# created_at :datetime not null
# updated_at :datetime not null
# block_id :bigint
#
# Indexes
#
# index_blockchain_pythnet_transactions_on_block_id (block_id)
# index_blockchain_pythnet_transactions_on_epoch (epoch)
#
class Blockchain::PythnetTransaction < Blockchain::Transaction
belongs_to :block, class_name: 'Blockchain::PythnetBlock', foreign_key: 'block_id', validate: false, optional: true
Expand Down
25 changes: 13 additions & 12 deletions app/models/blockchain/pythnet_transaction_archive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
#
# Table name: blockchain_pythnet_transaction_archives
#
# id :bigint not null, primary key
# account_key_1 :string(191)
# account_key_2 :string(191)
# account_key_3 :string(191)
# epoch :integer
# fee :bigint
# post_balances :text(65535)
# pre_balances :text(65535)
# slot_number :bigint
# created_at :datetime not null
# updated_at :datetime not null
# block_id :bigint
# id :bigint not null, primary key
# account_key_1 :string(191)
# account_key_2 :string(191)
# account_key_3 :string(191)
# epoch :integer
# fee :bigint
# post_balances :text(65535)
# pre_balances :text(65535)
# recent_blockhash :string(191)
# slot_number :bigint
# created_at :datetime not null
# updated_at :datetime not null
# block_id :bigint
#
class Blockchain::PythnetTransactionArchive < Blockchain::Archive
end
1 change: 1 addition & 0 deletions app/models/blockchain/testnet_block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#
# Indexes
#
# index_blockchain_testnet_blocks_on_blockhash (blockhash)
# index_blockchain_testnet_blocks_on_slot_number (slot_number)
#
class Blockchain::TestnetBlock < Blockchain::Block
Expand Down
26 changes: 14 additions & 12 deletions app/models/blockchain/testnet_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@
#
# Table name: blockchain_testnet_transactions
#
# id :bigint not null, primary key
# account_key_1 :string(191)
# account_key_2 :string(191)
# account_key_3 :string(191)
# epoch :integer
# fee :bigint
# post_balances :text(65535)
# pre_balances :text(65535)
# slot_number :bigint
# created_at :datetime not null
# updated_at :datetime not null
# block_id :bigint
# id :bigint not null, primary key
# account_key_1 :string(191)
# account_key_2 :string(191)
# account_key_3 :string(191)
# epoch :integer
# fee :bigint
# post_balances :text(65535)
# pre_balances :text(65535)
# recent_blockhash :string(191)
# slot_number :bigint
# created_at :datetime not null
# updated_at :datetime not null
# block_id :bigint
#
# Indexes
#
# index_blockchain_testnet_transactions_on_block_id (block_id)
# index_blockchain_testnet_transactions_on_epoch (epoch)
#
class Blockchain::TestnetTransaction < Blockchain::Transaction
belongs_to :block, class_name: 'Blockchain::TestnetBlock', foreign_key: 'block_id', validate: false, optional: true
Expand Down
25 changes: 13 additions & 12 deletions app/models/blockchain/testnet_transaction_archive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
#
# Table name: blockchain_testnet_transaction_archives
#
# id :bigint not null, primary key
# account_key_1 :string(191)
# account_key_2 :string(191)
# account_key_3 :string(191)
# epoch :integer
# fee :bigint
# post_balances :text(65535)
# pre_balances :text(65535)
# slot_number :bigint
# created_at :datetime not null
# updated_at :datetime not null
# block_id :bigint
# id :bigint not null, primary key
# account_key_1 :string(191)
# account_key_2 :string(191)
# account_key_3 :string(191)
# epoch :integer
# fee :bigint
# post_balances :text(65535)
# pre_balances :text(65535)
# recent_blockhash :string(191)
# slot_number :bigint
# created_at :datetime not null
# updated_at :datetime not null
# block_id :bigint
#
class Blockchain::TestnetTransactionArchive < Blockchain::Archive
end
1 change: 1 addition & 0 deletions app/services/blockchain/get_block_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def process_transactions
pre_balances: tx["meta"]["preBalances"],
slot_number: @slot_number,
block_id: @saved_block.id,
recent_blockhash: tx["transaction"]["message"]["recentBlockhash"],
epoch: @slot.epoch,
created_at: Time.now,
updated_at: Time.now
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class AddRecentBlockhashToBlockchainTransactions < ActiveRecord::Migration[6.1]
def change
add_column :blockchain_mainnet_transaction_archives, :recent_blockhash, :string
add_column :blockchain_testnet_transaction_archives, :recent_blockhash, :string
add_column :blockchain_pythnet_transaction_archives, :recent_blockhash, :string
add_column :blockchain_mainnet_transactions, :recent_blockhash, :string
add_column :blockchain_testnet_transactions, :recent_blockhash, :string
add_column :blockchain_pythnet_transactions, :recent_blockhash, :string

add_index :blockchain_mainnet_transactions, :epoch
add_index :blockchain_testnet_transactions, :epoch
add_index :blockchain_pythnet_transactions, :epoch
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class AddBlockhashIndexToBlockchainBlock < ActiveRecord::Migration[6.1]
def change
add_index :blockchain_mainnet_blocks, :blockhash
add_index :blockchain_testnet_blocks, :blockhash
add_index :blockchain_pythnet_blocks, :blockhash
end
end
14 changes: 13 additions & 1 deletion db/blockchain_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2024_08_20_073753) do
ActiveRecord::Schema.define(version: 2024_11_12_094122) do

create_table "blockchain_mainnet_block_archives", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.bigint "slot_number"
Expand All @@ -32,6 +32,7 @@
t.bigint "block_time"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["blockhash"], name: "index_blockchain_mainnet_blocks_on_blockhash"
t.index ["slot_number"], name: "index_blockchain_mainnet_blocks_on_slot_number"
end

Expand Down Expand Up @@ -66,6 +67,7 @@
t.bigint "block_id"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.string "recent_blockhash"
end

create_table "blockchain_mainnet_transactions", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
Expand All @@ -80,7 +82,9 @@
t.bigint "block_id"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.string "recent_blockhash"
t.index ["block_id"], name: "index_blockchain_mainnet_transactions_on_block_id"
t.index ["epoch"], name: "index_blockchain_mainnet_transactions_on_epoch"
end

create_table "blockchain_pythnet_block_archives", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
Expand All @@ -103,6 +107,7 @@
t.bigint "block_time"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["blockhash"], name: "index_blockchain_pythnet_blocks_on_blockhash"
t.index ["slot_number"], name: "index_blockchain_pythnet_blocks_on_slot_number"
end

Expand Down Expand Up @@ -137,6 +142,7 @@
t.bigint "block_id"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.string "recent_blockhash"
end

create_table "blockchain_pythnet_transactions", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
Expand All @@ -151,7 +157,9 @@
t.bigint "block_id"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.string "recent_blockhash"
t.index ["block_id"], name: "index_blockchain_pythnet_transactions_on_block_id"
t.index ["epoch"], name: "index_blockchain_pythnet_transactions_on_epoch"
end

create_table "blockchain_testnet_block_archives", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
Expand All @@ -174,6 +182,7 @@
t.bigint "block_time"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["blockhash"], name: "index_blockchain_testnet_blocks_on_blockhash"
t.index ["slot_number"], name: "index_blockchain_testnet_blocks_on_slot_number"
end

Expand Down Expand Up @@ -208,6 +217,7 @@
t.bigint "block_id"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.string "recent_blockhash"
end

create_table "blockchain_testnet_transactions", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
Expand All @@ -222,7 +232,9 @@
t.bigint "block_id"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.string "recent_blockhash"
t.index ["block_id"], name: "index_blockchain_testnet_transactions_on_block_id"
t.index ["epoch"], name: "index_blockchain_testnet_transactions_on_epoch"
end

end
6 changes: 3 additions & 3 deletions db/migrate/20240819091254_drop_slots.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class DropSlots < ActiveRecord::Migration[6.1]
def change
drop_table :blockchain_mainnet_slots, if_exists: true
drop_table :blockchain_testnet_slots, if_exists: true
drop_table :blockchain_pythnet_slots, if_exists: true
# drop_table :blockchain_mainnet_slots, if_exists: true
# drop_table :blockchain_testnet_slots, if_exists: true
# drop_table :blockchain_pythnet_slots, if_exists: true
end
end
6 changes: 3 additions & 3 deletions db/migrate/20240820065825_drop_transactions.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class DropTransactions < ActiveRecord::Migration[6.1]
def change
drop_table :blockchain_mainnet_transactions, if_exists: true
drop_table :blockchain_testnet_transactions, if_exists: true
drop_table :blockchain_pythnet_transactions, if_exists: true
# drop_table :blockchain_mainnet_transactions, if_exists: true
# drop_table :blockchain_testnet_transactions, if_exists: true
# drop_table :blockchain_pythnet_transactions, if_exists: true
end
end
6 changes: 3 additions & 3 deletions db/migrate/20240820070921_drop_blocks.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class DropBlocks < ActiveRecord::Migration[6.1]
def change
drop_table :blockchain_mainnet_blocks, if_exists: true
drop_table :blockchain_testnet_blocks, if_exists: true
drop_table :blockchain_pythnet_blocks, if_exists: true
# drop_table :blockchain_mainnet_blocks, if_exists: true
# drop_table :blockchain_testnet_blocks, if_exists: true
# drop_table :blockchain_pythnet_blocks, if_exists: true
end
end
6 changes: 3 additions & 3 deletions db/migrate/20240820073852_drop_archives.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class DropArchives < ActiveRecord::Migration[6.1]
def change
drop_table :blockchain_block_archives, if_exists: true
drop_table :blockchain_transaction_archives, if_exists: true
drop_table :blockchain_slot_archives, if_exists: true
# drop_table :blockchain_block_archives, if_exists: true
# drop_table :blockchain_transaction_archives, if_exists: true
# drop_table :blockchain_slot_archives, if_exists: true
end
end
Loading