remove diff unique constraint

This commit is contained in:
Ian Norden 2020-08-06 14:33:02 -05:00
parent 95067bda40
commit 97a64c174c
4 changed files with 6 additions and 5 deletions

View File

@ -8,7 +8,7 @@ CREATE TABLE eth.state_cids (
state_path BYTEA, state_path BYTEA,
node_type INTEGER, node_type INTEGER,
diff BOOLEAN NOT NULL DEFAULT FALSE, diff BOOLEAN NOT NULL DEFAULT FALSE,
UNIQUE (header_id, state_path, diff) UNIQUE (header_id, state_path)
); );
-- +goose Down -- +goose Down

View File

@ -8,7 +8,7 @@ CREATE TABLE eth.storage_cids (
storage_path BYTEA, storage_path BYTEA,
node_type INTEGER NOT NULL, node_type INTEGER NOT NULL,
diff BOOLEAN NOT NULL DEFAULT FALSE, diff BOOLEAN NOT NULL DEFAULT FALSE,
UNIQUE (state_id, storage_path, diff) UNIQUE (state_id, storage_path)
); );
-- +goose Down -- +goose Down

View File

@ -6,6 +6,7 @@
[leveldb] [leveldb]
path = "/Users/user/Library/Ethereum/geth/chaindata" path = "/Users/user/Library/Ethereum/geth/chaindata"
ancient = "/Users/user/Library/Ethereum/geth/chaindata/ancient"
[snapshot] [snapshot]
blockHeight = 0 blockHeight = -1

View File

@ -99,7 +99,7 @@ func (p *Publisher) PublishStateNode(node Node, headerID int64) (int64, error) {
} }
mhKey, _ := shared.MultihashKeyFromCIDString(stateCIDStr) mhKey, _ := shared.MultihashKeyFromCIDString(stateCIDStr)
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) 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_path = state_cids.state_path
RETURNING id`, RETURNING id`,
headerID, stateKey, stateCIDStr, node.Path, node.NodeType, false, mhKey).Scan(&stateID) headerID, stateKey, stateCIDStr, node.Path, node.NodeType, false, mhKey).Scan(&stateID)
return stateID, err return stateID, err
@ -131,7 +131,7 @@ func (p *Publisher) PublishStorageNode(node Node, stateID int64) error {
} }
mhKey, _ := shared.MultihashKeyFromCIDString(storageCIDStr) mhKey, _ := shared.MultihashKeyFromCIDString(storageCIDStr)
_, 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) _, 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 NOTHING`,
stateID, storageKey, storageCIDStr, node.Path, node.NodeType, false, mhKey) stateID, storageKey, storageCIDStr, node.Path, node.NodeType, false, mhKey)
return err return err
} }