forked from TrueCloudLab/neoneo-go
dao: add P2PStateExchangeExtensions
setting to dao.Version
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
f1767f361d
commit
582d489c90
2 changed files with 21 additions and 10 deletions
|
@ -309,6 +309,7 @@ func (bc *Blockchain) init() error {
|
||||||
StoragePrefix: storage.STStorage,
|
StoragePrefix: storage.STStorage,
|
||||||
StateRootInHeader: bc.config.StateRootInHeader,
|
StateRootInHeader: bc.config.StateRootInHeader,
|
||||||
P2PSigExtensions: bc.config.P2PSigExtensions,
|
P2PSigExtensions: bc.config.P2PSigExtensions,
|
||||||
|
P2PStateExchangeExtensions: bc.config.P2PStateExchangeExtensions,
|
||||||
KeepOnlyLatestState: bc.config.KeepOnlyLatestState,
|
KeepOnlyLatestState: bc.config.KeepOnlyLatestState,
|
||||||
Value: version,
|
Value: version,
|
||||||
}
|
}
|
||||||
|
@ -342,6 +343,10 @@ func (bc *Blockchain) init() error {
|
||||||
return fmt.Errorf("P2PSigExtensions setting mismatch (old=%t, new=%t",
|
return fmt.Errorf("P2PSigExtensions setting mismatch (old=%t, new=%t",
|
||||||
ver.P2PSigExtensions, bc.config.P2PSigExtensions)
|
ver.P2PSigExtensions, bc.config.P2PSigExtensions)
|
||||||
}
|
}
|
||||||
|
if ver.P2PStateExchangeExtensions != bc.config.P2PStateExchangeExtensions {
|
||||||
|
return fmt.Errorf("P2PStateExchangeExtensions setting mismatch (old=%t, new=%t",
|
||||||
|
ver.P2PStateExchangeExtensions, bc.config.P2PStateExchangeExtensions)
|
||||||
|
}
|
||||||
if ver.KeepOnlyLatestState != bc.config.KeepOnlyLatestState {
|
if ver.KeepOnlyLatestState != bc.config.KeepOnlyLatestState {
|
||||||
return fmt.Errorf("KeepOnlyLatestState setting mismatch: old=%v, new=%v",
|
return fmt.Errorf("KeepOnlyLatestState setting mismatch: old=%v, new=%v",
|
||||||
ver.KeepOnlyLatestState, bc.config.KeepOnlyLatestState)
|
ver.KeepOnlyLatestState, bc.config.KeepOnlyLatestState)
|
||||||
|
|
|
@ -381,6 +381,7 @@ type Version struct {
|
||||||
StoragePrefix storage.KeyPrefix
|
StoragePrefix storage.KeyPrefix
|
||||||
StateRootInHeader bool
|
StateRootInHeader bool
|
||||||
P2PSigExtensions bool
|
P2PSigExtensions bool
|
||||||
|
P2PStateExchangeExtensions bool
|
||||||
KeepOnlyLatestState bool
|
KeepOnlyLatestState bool
|
||||||
Value string
|
Value string
|
||||||
}
|
}
|
||||||
|
@ -388,6 +389,7 @@ type Version struct {
|
||||||
const (
|
const (
|
||||||
stateRootInHeaderBit = 1 << iota
|
stateRootInHeaderBit = 1 << iota
|
||||||
p2pSigExtensionsBit
|
p2pSigExtensionsBit
|
||||||
|
p2pStateExchangeExtensionsBit
|
||||||
keepOnlyLatestStateBit
|
keepOnlyLatestStateBit
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -413,6 +415,7 @@ func (v *Version) FromBytes(data []byte) error {
|
||||||
v.StoragePrefix = storage.KeyPrefix(data[i+1])
|
v.StoragePrefix = storage.KeyPrefix(data[i+1])
|
||||||
v.StateRootInHeader = data[i+2]&stateRootInHeaderBit != 0
|
v.StateRootInHeader = data[i+2]&stateRootInHeaderBit != 0
|
||||||
v.P2PSigExtensions = data[i+2]&p2pSigExtensionsBit != 0
|
v.P2PSigExtensions = data[i+2]&p2pSigExtensionsBit != 0
|
||||||
|
v.P2PStateExchangeExtensions = data[i+2]&p2pStateExchangeExtensionsBit != 0
|
||||||
v.KeepOnlyLatestState = data[i+2]&keepOnlyLatestStateBit != 0
|
v.KeepOnlyLatestState = data[i+2]&keepOnlyLatestStateBit != 0
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -426,6 +429,9 @@ func (v *Version) Bytes() []byte {
|
||||||
if v.P2PSigExtensions {
|
if v.P2PSigExtensions {
|
||||||
mask |= p2pSigExtensionsBit
|
mask |= p2pSigExtensionsBit
|
||||||
}
|
}
|
||||||
|
if v.P2PStateExchangeExtensions {
|
||||||
|
mask |= p2pStateExchangeExtensionsBit
|
||||||
|
}
|
||||||
if v.KeepOnlyLatestState {
|
if v.KeepOnlyLatestState {
|
||||||
mask |= keepOnlyLatestStateBit
|
mask |= keepOnlyLatestStateBit
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue