incoming invs and tx signing
when we get inv messages, txs are easy but blocks are a little tricky block heigh synchronization is done via os' file system signing is a bit inelegant (searches through inputs for pkscript matches) but fast enough in practice
This commit is contained in:
1 parent
01c35e62ab
commit
5a7c04bdb5
6 files changed
+170
-62
No files matched your search
+6
-6
@@ -23,7 +23,7 @@ import (
|
||||
const (
|
||||
targetTimespan = time.Hour * 24 * 14
|
||||
targetSpacing = time.Minute * 10
|
||||
epochLength = int64(targetTimespan / targetSpacing)
|
||||
epochLength = int32(targetTimespan / targetSpacing) // 2016
|
||||
maxDiffAdjust = 4
|
||||
minRetargetTimespan = int64(targetTimespan / maxDiffAdjust)
|
||||
maxRetargetTimespan = int64(targetTimespan * maxDiffAdjust)
|
||||
@@ -90,7 +90,7 @@ func calcDiffAdjust(start, end wire.BlockHeader, p *chaincfg.Params) uint32 {
|
||||
return blockchain.BigToCompact(newTarget)
|
||||
}
|
||||
|
||||
func CheckHeader(r io.ReadSeeker, height int64, p *chaincfg.Params) bool {
|
||||
func CheckHeader(r io.ReadSeeker, height int32, p *chaincfg.Params) bool {
|
||||
var err error
|
||||
var cur, prev, epochStart wire.BlockHeader
|
||||
// don't try to verfy the genesis block. That way madness lies.
|
||||
@@ -100,7 +100,7 @@ func CheckHeader(r io.ReadSeeker, height int64, p *chaincfg.Params) bool {
|
||||
// initial load of headers
|
||||
// load epochstart, previous and current.
|
||||
// get the header from the epoch start, up to 2016 blocks ago
|
||||
_, err = r.Seek(80*(height-(height%epochLength)), os.SEEK_SET)
|
||||
_, err = r.Seek(int64(80*(height-(height%epochLength))), os.SEEK_SET)
|
||||
if err != nil {
|
||||
log.Printf(err.Error())
|
||||
return false
|
||||
@@ -113,7 +113,7 @@ func CheckHeader(r io.ReadSeeker, height int64, p *chaincfg.Params) bool {
|
||||
// log.Printf("start epoch at height %d ", height-(height%epochLength))
|
||||
|
||||
// seek to n-1 header
|
||||
_, err = r.Seek(80*(height-1), os.SEEK_SET)
|
||||
_, err = r.Seek(int64(80*(height-1)), os.SEEK_SET)
|
||||
if err != nil {
|
||||
log.Printf(err.Error())
|
||||
return false
|
||||
@@ -125,7 +125,7 @@ func CheckHeader(r io.ReadSeeker, height int64, p *chaincfg.Params) bool {
|
||||
return false
|
||||
}
|
||||
// seek to curHeight header and read in
|
||||
_, err = r.Seek(80*(height), os.SEEK_SET)
|
||||
_, err = r.Seek(int64(80*(height)), os.SEEK_SET)
|
||||
if err != nil {
|
||||
log.Printf(err.Error())
|
||||
return false
|
||||
@@ -184,7 +184,7 @@ difficulty adjustments, and that they all link in to each other properly.
|
||||
This is the only blockchain technology in the whole code base.
|
||||
Returns false if anything bad happens. Returns true if the range checks
|
||||
out with no errors. */
|
||||
func CheckRange(r io.ReadSeeker, first, last int64, p *chaincfg.Params) bool {
|
||||
func CheckRange(r io.ReadSeeker, first, last int32, p *chaincfg.Params) bool {
|
||||
for i := first; i <= last; i++ {
|
||||
if !CheckHeader(r, i, p) {
|
||||
return false
|
||||
|
||||
Reference in new issue
Block a user