commit
36c783a479
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
9
main.go
9
main.go
@ -15,8 +15,15 @@
|
|||||||
|
|
||||||
package main
|
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() {
|
func main() {
|
||||||
|
logrus.SetFormatter(&logrus.TextFormatter{
|
||||||
|
FullTimestamp: true,
|
||||||
|
})
|
||||||
cmd.Execute()
|
cmd.Execute()
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user