diff --git a/app/jobs/commit_block_job.rb b/app/jobs/commit_block_job.rb index 1e600baa7..a678f27ad 100644 --- a/app/jobs/commit_block_job.rb +++ b/app/jobs/commit_block_job.rb @@ -21,7 +21,7 @@ def perform(block) # reject all the other cell output that is consumed by # transactions in current block - # collect all the previous cell outupts + # collect all the previous cell outputs # select related cell inputs which are not in current block # mark the transaction contains these cell input to be rejected diff --git a/app/models/bitcoin_transaction.rb b/app/models/bitcoin_transaction.rb index 40795e0a7..5867c4141 100644 --- a/app/models/bitcoin_transaction.rb +++ b/app/models/bitcoin_transaction.rb @@ -8,7 +8,7 @@ def confirmations raw_transaction = rpc.getrawtransaction(txid, 2) raw_transaction.dig("result", "confirmations") rescue StandardError => e - Rails.logger.error "get #{txid} confirmations faild: #{e.message}" + Rails.logger.error "get #{txid} confirmations failed: #{e.message}" 0 end end diff --git a/app/models/block.rb b/app/models/block.rb index 838cc73b5..18c15c114 100644 --- a/app/models/block.rb +++ b/app/models/block.rb @@ -32,7 +32,7 @@ class Block < ApplicationRecord belongs_to :parent_block, class_name: "Block", foreign_key: "parent_hash", primary_key: "block_hash", optional: true, inverse_of: :subsequent_blocks - # one block can have serveral different subsequent blocks, and only one can be included on chain + # one block can have several different subsequent blocks, and only one can be included on chain has_many :subsequent_blocks, class_name: "Block", foreign_key: "parent_hash", primary_key: "block_hash", inverse_of: :parent_block belongs_to :epoch_statistic, primary_key: :epoch_number, foreign_key: :epoch, optional: true diff --git a/db/migrate/20240902025657_drop_cell_outputs_old.rb b/db/migrate/20240902025657_drop_cell_outputs_old.rb new file mode 100644 index 000000000..2115df821 --- /dev/null +++ b/db/migrate/20240902025657_drop_cell_outputs_old.rb @@ -0,0 +1,5 @@ +class DropCellOutputsOld < ActiveRecord::Migration[7.0] + def change + drop_table :cell_outputs_old, if_exists: true + end +end diff --git a/db/structure.sql b/db/structure.sql index d28bfb536..8364d22af 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -1212,56 +1212,6 @@ CREATE TABLE public.cell_outputs_live ( ); --- --- Name: cell_outputs_old; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.cell_outputs_old ( - id bigint NOT NULL, - capacity numeric(64,2), - data bytea, - ckb_transaction_id bigint, - created_at timestamp without time zone NOT NULL, - updated_at timestamp without time zone NOT NULL, - status smallint DEFAULT 0, - address_id numeric(30,0), - block_id numeric(30,0), - tx_hash bytea, - cell_index integer, - consumed_by_id numeric(30,0), - cell_type integer DEFAULT 0, - data_size integer, - occupied_capacity numeric(30,0), - block_timestamp numeric(30,0), - consumed_block_timestamp numeric(30,0), - type_hash character varying, - udt_amount numeric(40,0), - dao character varying, - lock_script_id bigint, - type_script_id bigint, - data_hash bytea -); - - --- --- Name: cell_outputs_old_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.cell_outputs_old_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: cell_outputs_old_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.cell_outputs_old_id_seq OWNED BY public.cell_outputs_old.id; - - -- -- Name: cell_outputs_pending; Type: TABLE; Schema: public; Owner: - -- @@ -3059,13 +3009,6 @@ ALTER TABLE ONLY public.cell_inputs ALTER COLUMN id SET DEFAULT nextval('public. ALTER TABLE ONLY public.cell_outputs ALTER COLUMN id SET DEFAULT nextval('public.cell_outputs_id_seq'::regclass); --- --- Name: cell_outputs_old id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.cell_outputs_old ALTER COLUMN id SET DEFAULT nextval('public.cell_outputs_old_id_seq'::regclass); - - -- -- Name: ckb_transactions id; Type: DEFAULT; Schema: public; Owner: - -- @@ -3502,14 +3445,6 @@ ALTER TABLE ONLY public.cell_outputs_live ADD CONSTRAINT cell_outputs_live_pkey PRIMARY KEY (id, status); --- --- Name: cell_outputs_old cell_outputs_old_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.cell_outputs_old - ADD CONSTRAINT cell_outputs_old_pkey PRIMARY KEY (id); - - -- -- Name: cell_outputs_pending cell_outputs_pending_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -4702,97 +4637,6 @@ CREATE INDEX index_cell_dependencies_on_script_id ON public.cell_dependencies US CREATE UNIQUE INDEX index_cell_inputs_on_ckb_transaction_id_and_index ON public.cell_inputs USING btree (ckb_transaction_id, index); --- --- Name: index_cell_outputs_old_on_address_id_and_status; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_cell_outputs_old_on_address_id_and_status ON public.cell_outputs_old USING btree (address_id, status); - - --- --- Name: index_cell_outputs_old_on_block_id; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_cell_outputs_old_on_block_id ON public.cell_outputs_old USING btree (block_id); - - --- --- Name: index_cell_outputs_old_on_block_timestamp; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_cell_outputs_old_on_block_timestamp ON public.cell_outputs_old USING btree (block_timestamp); - - --- --- Name: index_cell_outputs_old_on_cell_type; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_cell_outputs_old_on_cell_type ON public.cell_outputs_old USING btree (cell_type); - - --- --- Name: index_cell_outputs_old_on_ckb_transaction_id_and_cell_index; Type: INDEX; Schema: public; Owner: - --- - -CREATE UNIQUE INDEX index_cell_outputs_old_on_ckb_transaction_id_and_cell_index ON public.cell_outputs_old USING btree (ckb_transaction_id, cell_index); - - --- --- Name: index_cell_outputs_old_on_consumed_block_timestamp; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_cell_outputs_old_on_consumed_block_timestamp ON public.cell_outputs_old USING btree (consumed_block_timestamp); - - --- --- Name: index_cell_outputs_old_on_consumed_by_id; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_cell_outputs_old_on_consumed_by_id ON public.cell_outputs_old USING btree (consumed_by_id); - - --- --- Name: index_cell_outputs_old_on_data_hash; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_cell_outputs_old_on_data_hash ON public.cell_outputs_old USING hash (data_hash); - - --- --- Name: index_cell_outputs_old_on_lock_script_id; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_cell_outputs_old_on_lock_script_id ON public.cell_outputs_old USING btree (lock_script_id); - - --- --- Name: index_cell_outputs_old_on_status; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_cell_outputs_old_on_status ON public.cell_outputs_old USING btree (status); - - --- --- Name: index_cell_outputs_old_on_tx_hash_and_cell_index; Type: INDEX; Schema: public; Owner: - --- - -CREATE UNIQUE INDEX index_cell_outputs_old_on_tx_hash_and_cell_index ON public.cell_outputs_old USING btree (tx_hash, cell_index); - - --- --- Name: index_cell_outputs_old_on_type_script_id; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_cell_outputs_old_on_type_script_id ON public.cell_outputs_old USING btree (type_script_id); - - --- --- Name: index_cell_outputs_old_on_type_script_id_and_id; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_cell_outputs_old_on_type_script_id_and_id ON public.cell_outputs_old USING btree (type_script_id, id); - - -- -- Name: index_contracts_on_code_hash; Type: INDEX; Schema: public; Owner: - -- @@ -6097,6 +5941,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('20240709131132'), ('20240709131713'), ('20240709142013'), -('20240822024448'); +('20240822024448'), +('20240902025657'); diff --git a/test/utils/ckb_utils_test.rb b/test/utils/ckb_utils_test.rb index 5770e246e..b21bc7498 100644 --- a/test/utils/ckb_utils_test.rb +++ b/test/utils/ckb_utils_test.rb @@ -296,7 +296,7 @@ class CkbUtilsTest < ActiveSupport::TestCase end end - test ".parse_dao should return nil whne dao is blank" do + test ".parse_dao should return nil when dao is blank" do assert_nil CkbUtils.parse_dao(nil) end