Bring README.md and doc.go examples up to date.
Since sqlite is now deprecated, update the examples to use levelb. Also, add false to the ProcessBlock calls for the fastAdd parameter.
This commit is contained in:
parent
84f6089bc9
commit
03394d6309
2 changed files with 5 additions and 5 deletions
|
@ -82,7 +82,7 @@ intentionally causes an error by attempting to process a duplicate block.
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/conformal/btcchain"
|
"github.com/conformal/btcchain"
|
||||||
"github.com/conformal/btcdb"
|
"github.com/conformal/btcdb"
|
||||||
_ "github.com/conformal/btcdb/sqlite3"
|
_ "github.com/conformal/btcdb/ldb"
|
||||||
"github.com/conformal/btcutil"
|
"github.com/conformal/btcutil"
|
||||||
"github.com/conformal/btcwire"
|
"github.com/conformal/btcwire"
|
||||||
"os"
|
"os"
|
||||||
|
@ -97,7 +97,7 @@ intentionally causes an error by attempting to process a duplicate block.
|
||||||
// database.
|
// database.
|
||||||
dbName := "example.db"
|
dbName := "example.db"
|
||||||
_ = os.Remove(dbName)
|
_ = os.Remove(dbName)
|
||||||
db, err := btcdb.CreateDB("sqlite", dbName)
|
db, err := btcdb.CreateDB("leveldb", dbName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Failed to create database: %v\n", err)
|
fmt.Printf("Failed to create database: %v\n", err)
|
||||||
return
|
return
|
||||||
|
@ -122,7 +122,7 @@ intentionally causes an error by attempting to process a duplicate block.
|
||||||
// Process a block. For this example, we are going to intentionally
|
// Process a block. For this example, we are going to intentionally
|
||||||
// cause an error by trying to process the genesis block which already
|
// cause an error by trying to process the genesis block which already
|
||||||
// exists.
|
// exists.
|
||||||
err = chain.ProcessBlock(genesisBlock)
|
err = chain.ProcessBlock(genesisBlock, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Failed to process block: %v\n", err)
|
fmt.Printf("Failed to process block: %v\n", err)
|
||||||
return
|
return
|
||||||
|
|
4
doc.go
4
doc.go
|
@ -72,7 +72,7 @@ intentionally causes an error by attempting to process a duplicate block.
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/conformal/btcchain"
|
"github.com/conformal/btcchain"
|
||||||
"github.com/conformal/btcdb"
|
"github.com/conformal/btcdb"
|
||||||
_ "github.com/conformal/btcdb/sqlite3"
|
_ "github.com/conformal/btcdb/ldb"
|
||||||
"github.com/conformal/btcutil"
|
"github.com/conformal/btcutil"
|
||||||
"github.com/conformal/btcwire"
|
"github.com/conformal/btcwire"
|
||||||
"os"
|
"os"
|
||||||
|
@ -87,7 +87,7 @@ intentionally causes an error by attempting to process a duplicate block.
|
||||||
// database.
|
// database.
|
||||||
dbName := "example.db"
|
dbName := "example.db"
|
||||||
_ = os.Remove(dbName)
|
_ = os.Remove(dbName)
|
||||||
db, err := btcdb.CreateDB("sqlite", dbName)
|
db, err := btcdb.CreateDB("leveldb", dbName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Failed to create database: %v\n", err)
|
fmt.Printf("Failed to create database: %v\n", err)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue