NewBlockCache return BlockCache instance
()
| 48 | |
| 49 | //NewBlockCache return BlockCache instance |
| 50 | func NewBlockCache() (*BlockCache, error) { |
| 51 | blockCache, err := lru.NewARC(BLOCK_CAHE_SIZE) |
| 52 | if err != nil { |
| 53 | return nil, fmt.Errorf("NewARC block error %s", err) |
| 54 | } |
| 55 | transactionCache, err := lru.NewARC(TRANSACTION_CACHE_SIZE) |
| 56 | if err != nil { |
| 57 | return nil, fmt.Errorf("NewARC header error %s", err) |
| 58 | } |
| 59 | return &BlockCache{ |
| 60 | blockCache: blockCache, |
| 61 | transactionCache: transactionCache, |
| 62 | }, nil |
| 63 | } |
| 64 | |
| 65 | //AddBlock to cache |
| 66 | func (this *BlockCache) AddBlock(block *types.Block) { |