Update README.md for btcnet changes.
The sample code in doc.go was updated for the recent btcnet changes, however the sample code in the README.md was not.
This commit is contained in:
parent
f37a5e76b5
commit
b0b090009a
1 changed files with 6 additions and 6 deletions
12
README.md
12
README.md
|
@ -83,8 +83,8 @@ intentionally causes an error by attempting to process a duplicate block.
|
||||||
"github.com/conformal/btcchain"
|
"github.com/conformal/btcchain"
|
||||||
"github.com/conformal/btcdb"
|
"github.com/conformal/btcdb"
|
||||||
_ "github.com/conformal/btcdb/ldb"
|
_ "github.com/conformal/btcdb/ldb"
|
||||||
|
"github.com/conformal/btcnet"
|
||||||
"github.com/conformal/btcutil"
|
"github.com/conformal/btcutil"
|
||||||
"github.com/conformal/btcwire"
|
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -95,20 +95,20 @@ intentionally causes an error by attempting to process a duplicate block.
|
||||||
// calls to os.Remove would not be used either, but again, we want
|
// calls to os.Remove would not be used either, but again, we want
|
||||||
// a complete working example here, so we make sure to remove the
|
// a complete working example here, so we make sure to remove the
|
||||||
// database.
|
// database.
|
||||||
dbName := "example.db"
|
dbName := "exampledb"
|
||||||
_ = os.Remove(dbName)
|
_ = os.RemoveAll(dbName)
|
||||||
db, err := btcdb.CreateDB("leveldb", 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
|
||||||
}
|
}
|
||||||
defer os.Remove(dbName) // Ignore error.
|
defer os.RemoveAll(dbName) // Ignore error.
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
// Insert the main network genesis block. This is part of the initial
|
// Insert the main network genesis block. This is part of the initial
|
||||||
// database setup. Like above, this typically would not be needed when
|
// database setup. Like above, this typically would not be needed when
|
||||||
// opening an existing database.
|
// opening an existing database.
|
||||||
genesisBlock := btcutil.NewBlock(&btcwire.GenesisBlock)
|
genesisBlock := btcutil.NewBlock(btcnet.MainNetParams.GenesisBlock)
|
||||||
_, err = db.InsertBlock(genesisBlock)
|
_, err = db.InsertBlock(genesisBlock)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Failed to insert genesis block: %v\n", err)
|
fmt.Printf("Failed to insert genesis block: %v\n", err)
|
||||||
|
@ -117,7 +117,7 @@ intentionally causes an error by attempting to process a duplicate block.
|
||||||
|
|
||||||
// Create a new BlockChain instance using the underlying database for
|
// Create a new BlockChain instance using the underlying database for
|
||||||
// the main bitcoin network and ignore notifications.
|
// the main bitcoin network and ignore notifications.
|
||||||
chain := btcchain.New(db, btcwire.MainNet, nil)
|
chain := btcchain.New(db, &btcnet.MainNetParams, nil)
|
||||||
|
|
||||||
// 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
|
||||||
|
|
Loading…
Reference in a new issue