core: add validUntilBlock field to transaction
1. closes #841 2. Commented out test cases where binary transaction are used. These test cases marked with `TODO NEO3.0: Update binary` and need to be updated. 3. Updated other tests. 4. Added cache to calculateValidUntilBlock() RPC-client method.
This commit is contained in:
parent
1e3c36433f
commit
5fa11987d2
16 changed files with 280 additions and 126 deletions
|
@ -24,6 +24,8 @@ const (
|
|||
defaultDialTimeout = 4 * time.Second
|
||||
defaultRequestTimeout = 4 * time.Second
|
||||
defaultClientVersion = "2.0"
|
||||
// number of blocks after which cache is expired
|
||||
cacheTimeout = 100
|
||||
)
|
||||
|
||||
// Client represents the middleman for executing JSON RPC calls
|
||||
|
@ -40,6 +42,7 @@ type Client struct {
|
|||
wif *keys.WIF
|
||||
balancerMu *sync.Mutex
|
||||
balancer request.BalanceGetter
|
||||
cache cache
|
||||
}
|
||||
|
||||
// Options defines options for the RPC client.
|
||||
|
@ -57,6 +60,18 @@ type Options struct {
|
|||
Version string
|
||||
}
|
||||
|
||||
// cache stores cache values for the RPC client methods
|
||||
type cache struct {
|
||||
calculateValidUntilBlock calculateValidUntilBlockCache
|
||||
}
|
||||
|
||||
// calculateValidUntilBlockCache stores cached number of validators and
|
||||
// cache expiration value in blocks
|
||||
type calculateValidUntilBlockCache struct {
|
||||
validatorsCount uint32
|
||||
expiresAt uint32
|
||||
}
|
||||
|
||||
// New returns a new Client ready to use.
|
||||
func New(ctx context.Context, endpoint string, opts Options) (*Client, error) {
|
||||
url, err := url.Parse(endpoint)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue