Browse Source

.

pull/9/head
Jae Kwon 10 years ago
parent
commit
6288d01c0e
7 changed files with 18 additions and 8 deletions
  1. +1
    -1
      blocks/account.go
  2. +1
    -1
      blocks/adjustment.go
  3. +1
    -1
      blocks/tx.go
  4. +7
    -1
      common/debounce.go
  5. +1
    -1
      common/heap.go
  6. +1
    -1
      common/panic.go
  7. +6
    -2
      merkle/iavl.go

+ 1
- 1
blocks/account.go View File

@ -27,7 +27,7 @@ func ReadAccountId(r io.Reader) AccountId {
case ACCOUNT_TYPE_BOTH:
return AccountId{t, ReadUInt64(r), ReadByteSlice(r)}
default:
panicf("Unknown AccountId type %x", t)
Panicf("Unknown AccountId type %x", t)
return AccountId{}
}
}


+ 1
- 1
blocks/adjustment.go View File

@ -54,7 +54,7 @@ func ReadAdjustment(r io.Reader) Adjustment {
VoteB: ReadVote(r),
}
default:
panicf("Unknown Adjustment type %x", t)
Panicf("Unknown Adjustment type %x", t)
return nil
}
}


+ 1
- 1
blocks/tx.go View File

@ -47,7 +47,7 @@ func ReadTx(r io.Reader) Tx {
Signature: ReadSignature(r),
}
default:
panicf("Unknown Tx type %x", t)
Panicf("Unknown Tx type %x", t)
return nil
}
}


+ 7
- 1
common/debounce.go View File

@ -2,6 +2,7 @@ package common
import (
"time"
"sync"
)
/* Debouncer */
@ -9,6 +10,7 @@ type Debouncer struct {
Ch chan struct{}
quit chan struct{}
dur time.Duration
mtx sync.Mutex
timer *time.Timer
}
@ -16,6 +18,7 @@ func NewDebouncer(dur time.Duration) *Debouncer {
var timer *time.Timer
var ch = make(chan struct{})
var quit = make(chan struct{})
var mtx sync.Mutex
fire := func() {
go func() {
select {
@ -23,17 +26,20 @@ func NewDebouncer(dur time.Duration) *Debouncer {
case <-quit:
}
}()
mtx.Lock(); defer mtx.Unlock()
timer.Reset(dur)
}
timer = time.AfterFunc(dur, fire)
return &Debouncer{Ch:ch, dur:dur, quit:quit, timer:timer}
return &Debouncer{Ch:ch, dur:dur, quit:quit, mtx:mtx, timer:timer}
}
func (d *Debouncer) Reset() {
d.mtx.Lock(); defer d.mtx.Unlock()
d.timer.Reset(d.dur)
}
func (d *Debouncer) Stop() bool {
d.mtx.Lock(); defer d.mtx.Unlock()
close(d.quit)
return d.timer.Stop()
}

+ 1
- 1
common/heap.go View File

@ -78,7 +78,7 @@ func (pq *priorityQueue) Pop() interface{} {
return item
}
func (pq *priorityQueue) Update(item *pqItem, value ByteSlice, priority int) {
func (pq *priorityQueue) Update(item *pqItem, value interface{}, priority int) {
heap.Remove(pq, item.index)
item.value = value
item.priority = priority


+ 1
- 1
common/panic.go View File

@ -4,6 +4,6 @@ import (
"fmt"
)
func panicf(s string, args ...interface{}) {
func Panicf(s string, args ...interface{}) {
panic(fmt.Sprintf(s, args...))
}

+ 6
- 2
merkle/iavl.go View File

@ -95,6 +95,9 @@ func (t *IAVLTree) Copy() Tree {
return &IAVLTree{db:t.db, root:t.root}
}
// Traverses all the nodes of the tree in prefix order.
// return true from cb to halt iteration.
// node.Height() == 0 if you just want a value node.
func (t *IAVLTree) Traverse(cb func(Node) bool) {
if t.root == nil { return }
t.root.traverse(t.db, cb)
@ -104,11 +107,12 @@ func (t *IAVLTree) Values() <-chan Value {
root := t.root
ch := make(chan Value)
go func() {
root.traverse(func(n Node) {
root.traverse(t.db, func(n Node) bool {
if n.Height() == 0 { ch <- n.Value() }
return true
})
close(ch)
}
}()
return ch
}


Loading…
Cancel
Save