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
|
@ -306,11 +306,12 @@ func (bc *Blockchain) init() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
bc.log.Info("no storage version found! creating genesis block")
|
bc.log.Info("no storage version found! creating genesis block")
|
||||||
ver = dao.Version{
|
ver = dao.Version{
|
||||||
StoragePrefix: storage.STStorage,
|
StoragePrefix: storage.STStorage,
|
||||||
StateRootInHeader: bc.config.StateRootInHeader,
|
StateRootInHeader: bc.config.StateRootInHeader,
|
||||||
P2PSigExtensions: bc.config.P2PSigExtensions,
|
P2PSigExtensions: bc.config.P2PSigExtensions,
|
||||||
KeepOnlyLatestState: bc.config.KeepOnlyLatestState,
|
P2PStateExchangeExtensions: bc.config.P2PStateExchangeExtensions,
|
||||||
Value: version,
|
KeepOnlyLatestState: bc.config.KeepOnlyLatestState,
|
||||||
|
Value: version,
|
||||||
}
|
}
|
||||||
if err = bc.dao.PutVersion(ver); err != nil {
|
if err = bc.dao.PutVersion(ver); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -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)
|
||||||
|
|
|
@ -378,16 +378,18 @@ func (dao *Simple) GetBlock(hash util.Uint256) (*block.Block, error) {
|
||||||
|
|
||||||
// Version represents current dao version.
|
// Version represents current dao version.
|
||||||
type Version struct {
|
type Version struct {
|
||||||
StoragePrefix storage.KeyPrefix
|
StoragePrefix storage.KeyPrefix
|
||||||
StateRootInHeader bool
|
StateRootInHeader bool
|
||||||
P2PSigExtensions bool
|
P2PSigExtensions bool
|
||||||
KeepOnlyLatestState bool
|
P2PStateExchangeExtensions bool
|
||||||
Value string
|
KeepOnlyLatestState bool
|
||||||
|
Value string
|
||||||
}
|
}
|
||||||
|
|
||||||
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