Skip to content

Commit

Permalink
Issue 393 (#1364)
Browse files Browse the repository at this point in the history
* feat: change epoch_statistics max_tx_cyles to bigint

Signed-off-by: Miles Zhang <[email protected]>

* feat: update cell_input's block_id's type description

Signed-off-by: Miles Zhang <[email protected]>

* refactor: remove unused code

Signed-off-by: Miles Zhang <[email protected]>

---------

Signed-off-by: Miles Zhang <[email protected]>
  • Loading branch information
zmcNotafraid authored Aug 2, 2023
1 parent 63fe95d commit 82c6056
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 72 deletions.
10 changes: 5 additions & 5 deletions app/models/cell_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def self.fill_missing_index(last_tx_id = 0)
# updated_at :datetime not null
# previous_cell_output_id :bigint
# from_cell_base :boolean default(FALSE)
# block_id :decimal(30, )
# block_id :bigint
# since :decimal(30, ) default(0)
# cell_type :integer default("normal")
# index :integer
Expand All @@ -105,8 +105,8 @@ def self.fill_missing_index(last_tx_id = 0)
#
# Indexes
#
# index_cell_inputs_on_block_id (block_id)
# index_cell_inputs_on_ckb_transaction_id_and_index (ckb_transaction_id,index) UNIQUE
# index_cell_inputs_on_previous_cell_output_id (previous_cell_output_id)
# index_cell_inputs_on_previous_tx_hash_and_previous_index (previous_tx_hash,previous_index)
# idx_cell_inputs_on_block_id (block_id)
# idx_cell_inputs_on_previous_cell_output_id (previous_cell_output_id)
# idx_cell_inputs_on_previous_tx_hash_and_previous_index (previous_tx_hash,previous_index)
# index_cell_inputs_on_ckb_transaction_id_and_index (ckb_transaction_id,index) UNIQUE
#
2 changes: 1 addition & 1 deletion app/models/epoch_statistic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def self.max_tx_cycles
# largest_tx_hash :binary
# largest_tx_bytes :integer
# max_block_cycles :bigint
# max_tx_cycles :integer
# max_tx_cycles :bigint
#
# Indexes
#
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
end
resources :dao_depositors, only: :index
resources :daily_statistics, only: :show
resources :block_statistics, only: :show
resources :block_statistics, only: :show ## TODO: unused route
resources :epoch_statistics, only: :show
resources :market_data, only: :show
resources :udts, only: %i(index show) do
Expand Down
1 change: 0 additions & 1 deletion config/routes/v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
get :ckb_transactions
get :deployed_cells
get :general_info
get :referring_cells
end
end

Expand Down
4 changes: 0 additions & 4 deletions config/schedule.dev.yml

This file was deleted.

42 changes: 0 additions & 42 deletions config/schedule.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ChangeMaxTxCyclesToEpochStatistic < ActiveRecord::Migration[7.0]
def change
change_column :epoch_statistics, :max_tx_cycles, :bigint
end
end
93 changes: 75 additions & 18 deletions db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ begin
insert into account_books (ckb_transaction_id, address_id)
values (row.id, i) ON CONFLICT DO NOTHING;
end loop;
END LOOP;
END LOOP;
close c;
end
$$;
Expand All @@ -196,21 +196,21 @@ DECLARE
if new.contained_address_ids is null then
new.contained_address_ids := array[]::int[];
end if;
if old is null
if old is null
then
to_add := new.contained_address_ids;
to_remove := array[]::int[];
else

to_add := array_subtract(new.contained_address_ids, old.contained_address_ids);
to_remove := array_subtract(old.contained_address_ids, new.contained_address_ids);
to_remove := array_subtract(old.contained_address_ids, new.contained_address_ids);
end if;

if to_add is not null then
FOREACH i IN ARRAY to_add
LOOP
LOOP
RAISE NOTICE 'ckb_tx_addr_id(%)', i;
insert into account_books (ckb_transaction_id, address_id)
insert into account_books (ckb_transaction_id, address_id)
values (new.id, i);
END LOOP;
end if;
Expand Down Expand Up @@ -779,10 +779,10 @@ ALTER SEQUENCE public.cell_dependencies_id_seq OWNED BY public.cell_dependencies


--
-- Name: cell_inputs; Type: TABLE; Schema: public; Owner: -
-- Name: cell_inputs_old; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cell_inputs (
CREATE TABLE public.cell_inputs_old (
id bigint NOT NULL,
ckb_transaction_id bigint,
created_at timestamp without time zone NOT NULL,
Expand Down Expand Up @@ -814,7 +814,27 @@ CREATE SEQUENCE public.cell_inputs_id_seq
-- Name: cell_inputs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.cell_inputs_id_seq OWNED BY public.cell_inputs.id;
ALTER SEQUENCE public.cell_inputs_id_seq OWNED BY public.cell_inputs_old.id;


--
-- Name: cell_inputs; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cell_inputs (
id bigint DEFAULT nextval('public.cell_inputs_id_seq'::regclass) NOT NULL,
ckb_transaction_id bigint,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
previous_cell_output_id bigint,
from_cell_base boolean DEFAULT false,
block_id bigint,
since numeric(30,0) DEFAULT 0.0,
cell_type integer DEFAULT 0,
index integer,
previous_tx_hash bytea,
previous_index integer
);


--
Expand Down Expand Up @@ -1243,7 +1263,7 @@ CREATE TABLE public.epoch_statistics (
largest_tx_hash bytea,
largest_tx_bytes integer,
max_block_cycles bigint,
max_tx_cycles integer
max_tx_cycles bigint
);


Expand Down Expand Up @@ -2401,10 +2421,10 @@ ALTER TABLE ONLY public.cell_dependencies ALTER COLUMN id SET DEFAULT nextval('p


--
-- Name: cell_inputs id; Type: DEFAULT; Schema: public; Owner: -
-- Name: cell_inputs_old id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cell_inputs ALTER COLUMN id SET DEFAULT nextval('public.cell_inputs_id_seq'::regclass);
ALTER TABLE ONLY public.cell_inputs_old ALTER COLUMN id SET DEFAULT nextval('public.cell_inputs_id_seq'::regclass);


--
Expand Down Expand Up @@ -2727,13 +2747,21 @@ ALTER TABLE ONLY public.cell_dependencies


--
-- Name: cell_inputs cell_inputs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
-- Name: cell_inputs_old cell_inputs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cell_inputs
ALTER TABLE ONLY public.cell_inputs_old
ADD CONSTRAINT cell_inputs_pkey PRIMARY KEY (id);


--
-- Name: cell_inputs cell_inputs_pkey_new; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cell_inputs
ADD CONSTRAINT cell_inputs_pkey_new PRIMARY KEY (id);


--
-- Name: cell_outputs cell_outputs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
Expand Down Expand Up @@ -3293,6 +3321,27 @@ CREATE INDEX ckb_transactions_rejected_tags_idx ON public.ckb_transactions_rejec
CREATE INDEX ckb_transactions_rejected_tx_hash_idx ON public.ckb_transactions_rejected USING hash (tx_hash);


--
-- Name: idx_cell_inputs_on_block_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_cell_inputs_on_block_id ON public.cell_inputs USING btree (block_id);


--
-- Name: idx_cell_inputs_on_previous_cell_output_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_cell_inputs_on_previous_cell_output_id ON public.cell_inputs USING btree (previous_cell_output_id);


--
-- Name: idx_cell_inputs_on_previous_tx_hash_and_previous_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_cell_inputs_on_previous_tx_hash_and_previous_index ON public.cell_inputs USING btree (previous_tx_hash, previous_index);


--
-- Name: index_account_books_on_address_id_and_ckb_transaction_id; Type: INDEX; Schema: public; Owner: -
--
Expand Down Expand Up @@ -3472,7 +3521,14 @@ CREATE INDEX index_cell_dependencies_on_script_id ON public.cell_dependencies US
-- Name: index_cell_inputs_on_block_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_cell_inputs_on_block_id ON public.cell_inputs USING btree (block_id);
CREATE INDEX index_cell_inputs_on_block_id ON public.cell_inputs_old USING btree (block_id);


--
-- Name: index_cell_inputs_on_ckb_transaction_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_cell_inputs_on_ckb_transaction_id ON public.cell_inputs_old USING btree (ckb_transaction_id);


--
Expand All @@ -3486,14 +3542,14 @@ CREATE UNIQUE INDEX index_cell_inputs_on_ckb_transaction_id_and_index ON public.
-- Name: index_cell_inputs_on_previous_cell_output_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_cell_inputs_on_previous_cell_output_id ON public.cell_inputs USING btree (previous_cell_output_id);
CREATE INDEX index_cell_inputs_on_previous_cell_output_id ON public.cell_inputs_old USING btree (previous_cell_output_id);


--
-- Name: index_cell_inputs_on_previous_tx_hash_and_previous_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_cell_inputs_on_previous_tx_hash_and_previous_index ON public.cell_inputs USING btree (previous_tx_hash, previous_index);
CREATE INDEX index_cell_inputs_on_previous_tx_hash_and_previous_index ON public.cell_inputs_old USING btree (previous_tx_hash, previous_index);


--
Expand Down Expand Up @@ -4610,6 +4666,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20230622143224'),
('20230622143339'),
('20230630112234'),
('20230711040233');
('20230711040233'),
('20230802015907');


0 comments on commit 82c6056

Please sign in to comment.