-
Notifications
You must be signed in to change notification settings - Fork 199
/
bootstrapBlockchain.go
39 lines (31 loc) · 1.01 KB
/
bootstrapBlockchain.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package blockchain
import (
"sync"
"github.com/multiversx/mx-chain-core-go/data"
)
type bootstrapBlockchain struct {
currentBlockHeader data.HeaderHandler
mut sync.RWMutex
}
// NewBootstrapBlockchain returns a new instance of bootstrapBlockchain
// It should be used for bootstrap only!
func NewBootstrapBlockchain() *bootstrapBlockchain {
return &bootstrapBlockchain{}
}
// GetCurrentBlockHeader returns the current block header
func (bbc *bootstrapBlockchain) GetCurrentBlockHeader() data.HeaderHandler {
bbc.mut.RLock()
defer bbc.mut.RUnlock()
return bbc.currentBlockHeader
}
// SetCurrentBlockHeaderAndRootHash returns nil always and saves the current block header
func (bbc *bootstrapBlockchain) SetCurrentBlockHeaderAndRootHash(bh data.HeaderHandler, _ []byte) error {
bbc.mut.Lock()
defer bbc.mut.Unlock()
bbc.currentBlockHeader = bh
return nil
}
// IsInterfaceNil returns true if there is no value under the interface
func (bbc *bootstrapBlockchain) IsInterfaceNil() bool {
return bbc == nil
}