Browse Source

:ledger: Store only necessary in memory

Ettore Di Giacinto 3 years ago
parent
commit
4150820335
2 changed files with 6 additions and 6 deletions
  1. 5 5
      pkg/blockchain/store_memory.go
  2. 1 1
      pkg/edgevpn/options.go

+ 5 - 5
pkg/blockchain/store_memory.go

@@ -1,21 +1,21 @@
 package blockchain
 
 type memory struct {
-	chain Blockchain
+	block *Block
 }
 
 func (m *memory) Add(b Block) {
-	m.chain = append(m.chain, b)
+	m.block = &b
 }
 
 func (m *memory) Reset() {
-	m.chain = []Block{}
+	m.block = &Block{}
 }
 
 func (m *memory) Len() int {
-	return len(m.chain)
+	return m.block.Index
 }
 
 func (m *memory) Last() Block {
-	return m.chain[len(m.chain)-1]
+	return *m.block
 }

+ 1 - 1
pkg/edgevpn/options.go

@@ -241,7 +241,7 @@ func GenerateNewConnectionData() (*YAMLConnectionConfig, error) {
 	config.OTP.Crypto.Interval = 9000
 	config.OTP.Crypto.Length = 12
 	config.OTP.DHT.Length = 12
-	config.MaxBlockChainLength = 400
+	config.MaxBlockChainLength = 0
 	config.MaxMessageSize = 20 << 20 // 20MB
 
 	return &config, nil