forked from TrueCloudLab/neoneo-go
storage: drop Len from the Batch interface
It's almost meaningless now and we can easily live without it.
This commit is contained in:
parent
e111892653
commit
3ada92944a
3 changed files with 2 additions and 7 deletions
|
@ -238,6 +238,7 @@ func (bc *Blockchain) AddHeaders(headers ...*Header) (err error) {
|
||||||
)
|
)
|
||||||
|
|
||||||
bc.headersOp <- func(headerList *HeaderHashList) {
|
bc.headersOp <- func(headerList *HeaderHashList) {
|
||||||
|
oldlen := headerList.Len()
|
||||||
for _, h := range headers {
|
for _, h := range headers {
|
||||||
if int(h.Index-1) >= headerList.Len() {
|
if int(h.Index-1) >= headerList.Len() {
|
||||||
err = fmt.Errorf(
|
err = fmt.Errorf(
|
||||||
|
@ -258,7 +259,7 @@ func (bc *Blockchain) AddHeaders(headers ...*Header) (err error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if batch.Len() > 0 {
|
if oldlen != headerList.Len() {
|
||||||
if err = bc.memStore.PutBatch(batch); err != nil {
|
if err = bc.memStore.PutBatch(batch); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,11 +37,6 @@ func (b *MemoryBatch) Delete(k []byte) {
|
||||||
b.del[kcopy] = true
|
b.del[kcopy] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Len implements the Batch interface.
|
|
||||||
func (b *MemoryBatch) Len() int {
|
|
||||||
return len(b.m)
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewMemoryStore creates a new MemoryStore object.
|
// NewMemoryStore creates a new MemoryStore object.
|
||||||
func NewMemoryStore() *MemoryStore {
|
func NewMemoryStore() *MemoryStore {
|
||||||
return &MemoryStore{
|
return &MemoryStore{
|
||||||
|
|
|
@ -46,7 +46,6 @@ type (
|
||||||
Batch interface {
|
Batch interface {
|
||||||
Delete(k []byte)
|
Delete(k []byte)
|
||||||
Put(k, v []byte)
|
Put(k, v []byte)
|
||||||
Len() int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// KeyPrefix is a constant byte added as a prefix for each key
|
// KeyPrefix is a constant byte added as a prefix for each key
|
||||||
|
|
Loading…
Reference in a new issue