dao: simplify buffer management for private DAO
Private DAO is only used in a single thread which means we can safely reuse key/data buffers most of the time and handle it all in DAO. Doesn't affect any benchmarks.
This commit is contained in:
parent
9bfb3357f2
commit
7dc8fc443f
5 changed files with 102 additions and 78 deletions
|
@ -330,19 +330,16 @@ func (s *Module) AddBlock(block *block.Block) error {
|
|||
}
|
||||
}
|
||||
cache := s.dao.GetPrivate()
|
||||
writeBuf := io.NewBufBinWriter()
|
||||
if err := cache.StoreAsBlock(block, nil, nil, writeBuf); err != nil {
|
||||
if err := cache.StoreAsBlock(block, nil, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
writeBuf.Reset()
|
||||
|
||||
cache.PutStateSyncCurrentBlockHeight(block.Index)
|
||||
|
||||
for _, tx := range block.Transactions {
|
||||
if err := cache.StoreAsTransaction(tx, block.Index, nil, writeBuf); err != nil {
|
||||
if err := cache.StoreAsTransaction(tx, block.Index, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
writeBuf.Reset()
|
||||
}
|
||||
|
||||
_, err := cache.Persist()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue