start trying to connect to segnet

doesn't work or anything yet
This commit is contained in:
Tadge Dryja 2016-02-10 13:22:15 -08:00
parent 2cbe605221
commit 7fdcf9bfbc
3 changed files with 11 additions and 8 deletions

@ -25,15 +25,15 @@ testing. It can send and receive coins.
const ( const (
keyFileName = "testkey.hex" keyFileName = "testkey.hex"
headerFileName = "headers.bin" headerFileName = "headers.bin"
dbFileName = "/dev/shm/utxo.db" dbFileName = "utxo.db"
// this is my local testnet node, replace it with your own close by. // this is my local testnet node, replace it with your own close by.
// Random internet testnet nodes usually work but sometimes don't, so // Random internet testnet nodes usually work but sometimes don't, so
// maybe I should test against different versions out there. // maybe I should test against different versions out there.
SPVHostAdr = "127.0.0.1:18333" SPVHostAdr = "127.0.0.1:28333"
) )
var ( var (
Params = &chaincfg.TestNet3Params Params = &chaincfg.SegNetParams
SCon uspv.SPVCon // global here for now SCon uspv.SPVCon // global here for now
) )
@ -51,7 +51,7 @@ func shell() {
// setup spvCon // setup spvCon
SCon, err = uspv.OpenSPV( SCon, err = uspv.OpenSPV(
SPVHostAdr, headerFileName, dbFileName, &Store, false, false, Params) SPVHostAdr, headerFileName, dbFileName, &Store, true, false, Params)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
@ -61,7 +61,7 @@ func shell() {
log.Fatal(err) log.Fatal(err)
} }
if tip == 0 { // DB has never been used, set to birthday if tip == 0 { // DB has never been used, set to birthday
tip = 675000 // hardcoded; later base on keyfile date? tip = 1234 // hardcoded; later base on keyfile date?
err = SCon.TS.SetDBSyncHeight(tip) err = SCon.TS.SetDBSyncHeight(tip)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)

@ -15,7 +15,8 @@ const (
headerFileName = "headers.bin" headerFileName = "headers.bin"
// version hardcoded for now, probably ok...? // version hardcoded for now, probably ok...?
VERSION = 70011 // 70012 is for segnet... make this a init var?
VERSION = 70012
) )
type SPVCon struct { type SPVCon struct {
@ -115,7 +116,9 @@ func (s *SPVCon) IngestMerkleBlock(m *wire.MsgMerkleBlock) {
// into our SPV header file // into our SPV header file
newMerkBlockSha := m.Header.BlockSha() newMerkBlockSha := m.Header.BlockSha()
if !hah.blockhash.IsEqual(&newMerkBlockSha) { if !hah.blockhash.IsEqual(&newMerkBlockSha) {
log.Printf("merkle block out of order error") log.Printf("merkle block out of order got %s expect %s",
m.Header.BlockSha().String(), hah.blockhash.String())
log.Printf("has %d hashes", len(m.Hashes))
return return
} }

@ -128,7 +128,7 @@ func (s *SPVCon) TxHandler(m *wire.MsgTx) {
height, ok := s.TS.OKTxids[m.TxSha()] height, ok := s.TS.OKTxids[m.TxSha()]
s.TS.OKMutex.Unlock() s.TS.OKMutex.Unlock()
if !ok { if !ok {
log.Printf("Tx %s unknown, will not ingest\n") log.Printf("Tx %s unknown, will not ingest\n", m.TxSha().String())
return return
} }