Merge pull request #5 from vulcanize/snapshot

Minor updates
This commit is contained in:
Ian Norden 2020-08-10 13:05:34 -05:00 committed by GitHub
commit 36c783a479
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

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

View File

@ -15,8 +15,15 @@
package main
import "github.com/vulcanize/eth-pg-ipfs-state-snapshot/cmd"
import (
"github.com/sirupsen/logrus"
"github.com/vulcanize/eth-pg-ipfs-state-snapshot/cmd"
)
func main() {
logrus.SetFormatter(&logrus.TextFormatter{
FullTimestamp: true,
})
cmd.Execute()
}

View File

@ -99,7 +99,7 @@ func (p *Publisher) PublishStateNode(node Node, headerID int64) (int64, error) {
}
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)
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`,
headerID, stateKey, stateCIDStr, node.Path, node.NodeType, false, mhKey).Scan(&stateID)
return stateID, err
@ -131,7 +131,7 @@ func (p *Publisher) PublishStorageNode(node Node, stateID int64) error {
}
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)
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)
return err
}