diff --git a/README.md b/README.md index 2748c8e6..a410d3cc 100644 --- a/README.md +++ b/README.md @@ -130,6 +130,8 @@ Then, build the binary: `make build` +Note: go modules needs to be turned on `export GO111MODULE=on` + ## Usage After building the binary, run as @@ -200,7 +202,7 @@ For Ethereum: A number of different APIs for remote access to ipfs-blockchain-watcher data can be exposed, these are discussed in more detail [here](./documentation/apis.md) ### Testing -`make test` will run the unit tests +`make test` will run the unit tests `make test` setups a clean `vulcanize_testing` db ## Contributing diff --git a/db/migrations/00008_create_eth_state_cids_table.sql b/db/migrations/00008_create_eth_state_cids_table.sql index 4bfa8228..e0bf6e57 100644 --- a/db/migrations/00008_create_eth_state_cids_table.sql +++ b/db/migrations/00008_create_eth_state_cids_table.sql @@ -8,7 +8,7 @@ CREATE TABLE eth.state_cids ( state_path BYTEA, node_type INTEGER, diff BOOLEAN NOT NULL DEFAULT FALSE, - UNIQUE (header_id, state_path, diff) + UNIQUE (header_id, state_path) ); -- +goose Down diff --git a/db/migrations/00009_create_eth_storage_cids_table.sql b/db/migrations/00009_create_eth_storage_cids_table.sql index f19bc62e..944d39ed 100644 --- a/db/migrations/00009_create_eth_storage_cids_table.sql +++ b/db/migrations/00009_create_eth_storage_cids_table.sql @@ -8,7 +8,7 @@ CREATE TABLE eth.storage_cids ( storage_path BYTEA, node_type INTEGER NOT NULL, diff BOOLEAN NOT NULL DEFAULT FALSE, - UNIQUE (state_id, storage_path, diff) + UNIQUE (state_id, storage_path) ); -- +goose Down diff --git a/db/schema.sql b/db/schema.sql index a3b55a44..caa1bb67 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -774,11 +774,11 @@ ALTER TABLE ONLY eth.state_accounts -- --- Name: state_cids state_cids_header_id_state_path_diff_key; Type: CONSTRAINT; Schema: eth; Owner: - +-- Name: state_cids state_cids_header_id_state_path_key; Type: CONSTRAINT; Schema: eth; Owner: - -- ALTER TABLE ONLY eth.state_cids - ADD CONSTRAINT state_cids_header_id_state_path_diff_key UNIQUE (header_id, state_path, diff); + ADD CONSTRAINT state_cids_header_id_state_path_key UNIQUE (header_id, state_path); -- @@ -798,11 +798,11 @@ ALTER TABLE ONLY eth.storage_cids -- --- Name: storage_cids storage_cids_state_id_storage_path_diff_key; Type: CONSTRAINT; Schema: eth; Owner: - +-- Name: storage_cids storage_cids_state_id_storage_path_key; Type: CONSTRAINT; Schema: eth; Owner: - -- ALTER TABLE ONLY eth.storage_cids - ADD CONSTRAINT storage_cids_state_id_storage_path_diff_key UNIQUE (state_id, storage_path, diff); + ADD CONSTRAINT storage_cids_state_id_storage_path_key UNIQUE (state_id, storage_path); -- diff --git a/pkg/eth/indexer.go b/pkg/eth/indexer.go index 4285c9fa..ff57d2d4 100644 --- a/pkg/eth/indexer.go +++ b/pkg/eth/indexer.go @@ -150,7 +150,7 @@ func (in *CIDIndexer) indexStateAndStorageCIDs(tx *sqlx.Tx, payload *CIDPayload, stateKey = stateCID.StateKey } err := tx.QueryRowx(`INSERT INTO eth.state_cids (header_id, state_leaf_key, cid, state_path, node_type, diff, mh_key) VALUES ($1, $2, $3, $4, $5, $6, $7) - ON CONFLICT (header_id, state_path, diff) DO UPDATE SET (state_leaf_key, cid, node_type, mh_key) = ($2, $3, $5, $7) + ON CONFLICT (header_id, state_path) DO UPDATE SET (state_leaf_key, cid, node_type, diff, mh_key) = ($2, $3, $5, $6, $7) RETURNING id`, headerID, stateKey, stateCID.CID, stateCID.Path, stateCID.NodeType, true, stateCID.MhKey).Scan(&stateID) if err != nil { @@ -181,7 +181,7 @@ func (in *CIDIndexer) indexStateCID(tx *sqlx.Tx, stateNode StateNodeModel, heade stateKey = stateNode.StateKey } err := tx.QueryRowx(`INSERT INTO eth.state_cids (header_id, state_leaf_key, cid, state_path, node_type, diff, mh_key) VALUES ($1, $2, $3, $4, $5, $6, $7) - ON CONFLICT (header_id, state_path, diff) DO UPDATE SET (state_leaf_key, cid, node_type, mh_key) = ($2, $3, $5, $7) + ON CONFLICT (header_id, state_path) DO UPDATE SET (state_leaf_key, cid, node_type, diff, mh_key) = ($2, $3, $5, $6, $7) RETURNING id`, headerID, stateKey, stateNode.CID, stateNode.Path, stateNode.NodeType, true, stateNode.MhKey).Scan(&stateID) return stateID, err @@ -200,7 +200,7 @@ func (in *CIDIndexer) indexStorageCID(tx *sqlx.Tx, storageCID StorageNodeModel, storageKey = storageCID.StorageKey } _, err := tx.Exec(`INSERT INTO eth.storage_cids (state_id, storage_leaf_key, cid, storage_path, node_type, diff, mh_key) VALUES ($1, $2, $3, $4, $5, $6, $7) - ON CONFLICT (state_id, storage_path, diff) DO UPDATE SET (storage_leaf_key, cid, node_type, mh_key) = ($2, $3, $5, $7)`, + ON CONFLICT (state_id, storage_path) DO UPDATE SET (storage_leaf_key, cid, node_type, diff, mh_key) = ($2, $3, $5, $6, $7)`, stateID, storageKey, storageCID.CID, storageCID.Path, storageCID.NodeType, true, storageCID.MhKey) return err }