hash method

String hash()
override

Generates a hash that uniquely identifies this request's method invocation.

The hash is derived by JSON encoding the request's method and params. Two JsonRpcRequests will produce the same hash if they contain the same method and ordered params.

final p0 = ['Gr54...5Fd5', { 'encoding': 'base64', 'commitment': 'finalized' }];
final r0 = JsonRpcRequest(Method.getAccountInfo, params: p0, id: 0);

final p1 = ['Gr54...5Fd5', { 'encoding': 'base64', 'commitment': 'finalized' }];
final r1 = JsonRpcRequest(Method.getAccountInfo, params: p1, id: 1);

final p2 = ['Gr54...5Fd5', { 'commitment': 'finalized', 'encoding': 'base64' }];
final r2 = JsonRpcRequest(Method.getAccountInfo, params: p2, id: 1);

assert(r0.hash() == r1.hash()); // true
assert(r1.hash() == r2.hash()); // false, the configuration values are ordered differently.

TODO: Sort by keys, then hash.

Implementation

String hash() => json.encode([method.name, params]);